I am trying to implement my first phonegap plugin (version 2.3) on iOS - but the call of the native function seems not to work.
My plugin is based on this introduction: http://docs.phonegap.com/en/2.3.0/guide_plugin-development_ios_index.md.html#Developing%20a%20Plugin%20on%20iOS
So I added to the plugins-section of config.xml:
<plugin name="Echo" value="Echo" />
my calling javascript:
$(document).ready (function (){
$('#testBtn').submit(function () {
alert("test");
var param = ["a", false];
cordova.exec(
function(winParam) { alert("ok"); },
function(err) { alert("error"); },
"Echo", "echo", param);
return false;
});
}
(the alert in the first row gets called by pushing my testBtn, so the rest should also be executed...)
In my plugins-directory:
Echo.h:
#import <Cordova/CDV.h>
@interface Echo : CDVPlugin
- (void)echo:(CDVInvokedUrlCommand*)command;
@end
Echo.m:
#import "Echo.h"
@implementation Echo
- (void)echo:(CDVInvokedUrlCommand*)command
{
NSLog(@"echo!");
}
@end
The echo-Function in Echo.m never gets called ... can anyone tell me why? I don't get any error messages - just nothing happens...
I was struggling in this step like you. then I Called that javascript function after device getting ready. Problem has solved. Now, Its working fine...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.