PushPlugin not found, or is not a CDVPlugin

大憨熊 提交于 2019-12-08 04:15:58

问题


I am developing an app using Cordova, Angular and Ionic. I have a problem with the phonegap push plugin and I've searched a lot but no solutions found.

I use cordova 5.4.1 and phonegap-plugin-push 1.5.3. When I run the app on iPad or emulator from Xcode, logs throws this error:

 ERROR: Plugin 'PushPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
 [CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = [
  "PushPlugin938856013",
  "PushPlugin",
  "register",
  [{
     "ecb":"onNotificationAPN",
     "alert":"true",
     "badge":"true",
     "sound":"true"
  }]
 ]

I've reinstalled the plugin several times, removing/ adding the ios platform, and nothing works. I`ve also tried adding on config.xml lines like:

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

But doesn't work.

I've read for including PushPlugin.m in build phases on Xcode and PushPlugin.h in plugin forlder too, but both alredy in. I can see how Xcode is compiling the plugin (and generating some warnings ), everything seems normal, but for some reason it can't be included on the app.

Like I've said, I've wasted a lot of time searching and trying solutions, but nothing works.. Could anybody help me, please?


回答1:


https://github.com/phonegap-build/PushPlugin#description

Important - Push notifications are intended for real devices. They are not tested for WP8 Emulator. The registration process will fail on the iOS simulator.

But I guess for what its worth, try cordova plugin add phonegap-plugin-push --save as phonegap/phonegap-plugin-push is the new unified version




回答2:


I'm happy to say that, after two weeks, I've found the solution! When I thought I'm getting crazy, the plugin finally works! I was initializing the plugin by the wrong (and old) way. I replaced my init code with:

        var pushNotification = PushNotification.init({
            "android": {
                "senderID": "1234567890"
            },
            "ios": {"alert": "true", "badge": "true", "sound": "true"}, 
            "windows": {} 
        });

        pushNotification.on('registration', function(data) {
            console.log("registration event");
            console.log(JSON.stringify(data));
        });

        pushNotification.on('notification', function(data) {
            console.log("notification event");
            console.log(JSON.stringify(data));

            pushNotification.finish(function () {
                console.log('finish successfully called');
            });
        });

        pushNotification.on('error', function(e) {
            console.log("push error");
        });

And it works! Many thanks for you help, @Dwardu!



来源:https://stackoverflow.com/questions/35430445/pushplugin-not-found-or-is-not-a-cdvplugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!