我正在尝试使用PushPlugin开发iOS应用程序。我面临以下错误:

DEPRECATION NOTICE: The Connection ReachableViaWWAN return value of '2g' is deprecated as of Cordova version 2.6.0 and will be changed to 'cellular' in a future release.

2013-12-23 17:19:52.362 myApp[537:60b] CDVPlugin class PushPlugin (pluginName: PushPlugin) does not exist.

2013-12-23 17:19:52.363 miniOrangeAuthenticator[537:60b] ERROR: Plugin 'PushPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.

2013-12-23 17:19:52.364 miniOrangeAuthenticator[537:60b] -[CDVCommandQueue executePending] [Line 116] FAILED pluginJSON = [

  "PushPlugin1458195152",

  "PushPlugin",

  "register",

  [

    {

      "alert" : "true",

      "ecb" : "onNotificationAPN",

      "sound" : "true",

      "badge" : "true"

    }

  ]

]


我在config.xml文件中添加了依赖项,如下所示:

<feature>
    <param name="ios-package" value="PushPlugin" />
</feature>


我还尝试了使用以下代码的旧插件格式:

<plugin name="PushPlugin" value="com.phonegap.plugins.PushPlugin" />


即使那样也给了我同样的错误。

我正在真正的iOS设备上尝试。

这里可能是什么问题?

最佳答案

您正在使用哪个版本的cordova?
我在Cordova 2.9中安装了该插件,并且记得在xcode中导入文件时遇到了一些问题。
如果您在iOS上使用cordova 3.x,则只需通过命令行添加插件(在android上,您还必须手动复制文件,但在iOS上则没有必要)。

编辑以评论中的问题:我唯一能想到的是您在触发“设备就绪”事件之前初始化插件。这是我使用的代码:

var initPushNotification = function() {
    var pushNotification = window.plugins.pushNotification;
    pushNotification.register(
        tokenHandler,
        errorHandler, {
            "badge":"true",
            "sound":"true",
            "alert":"true",
            "ecb":"onNotificationAPN"
        });
};

function onDeviceReady() {
    // other stuff here...
    initPushNotification();
}

关于ios - 使用Cordova在iOS应用程序中找不到PushPlugin,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20743106/

10-11 22:21
查看更多