PushPlugin not found, or is not a CDVPlugin

三世轮回 提交于 2019-12-09 07:32:27

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

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!

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