|
|
I'm trying to create a custom sample cordova plugin in my ionic+angular app but I'm not able to make it work. I've added the feature in config.xml in the xcode root |
cordova.exec(
function(data){
alert(data)
},
function(){
alert("Errore")
},
"SayHelloPlugin",
"sayHello",
["Andrea"]
);
And finally I've created the SayHelloPlugin class in the classes folder of xcode
SayHelloPlugin.h
#import <Foundation/Foundation.h>
#import <Cordova/CDV.h>
@interface SayHelloPlugin : CDVPlugin
- (void)sayHello:(CDVInvokedUrlCommand*)command;
@end
SayHelloPlugin.m#import "SayHelloPlugin.h"
@implementation SayHelloPlugin
- (void)sayHello:(CDVInvokedUrlCommand*)command {
NSString *responseString = [NSString stringWithFormat:@"Hello %@", [command.arguments objectAtIndex:0]];
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:responseString];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end
But when I try to call the plugin it throws an error ERROR: Plugin 'SayHelloPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
I've already tried to wrap the cordova.exec in $ionicPlatform.ready() function, I've tried to remove and re-add the ios platform, I tried to create a plugin.xml in the project root without success.