简体   繁体   English

iOS上的Phonegap插件未调用本机代码

[英]Phonegap plugin on iOS not calling native code

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. 我正在尝试在iOS上实现我的第一个phonegap插件(2.3版)-但是调用本机函数似乎无法正常工作。

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 我的插件基于以下介绍: 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: 所以我在config.xml的plugins-section中添加了:

<plugin name="Echo" value="Echo" />

my calling javascript: 我的呼叫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...) (通过推送我的testBtn调用第一行中的警报,因此其余的也应执行...)

In my plugins-directory: 在我的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? 永远不会调用Echo.m中的echo-Function ...谁能告诉我为什么? 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. 然后在设备准备就绪后调用该javascript函数。 Problem has solved. 问题解决了。 Now, Its working fine... 现在,它的工作正常...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM