3

Few days ago, I succeeded in messaging my phone with push plugin. But now, after pushNotification.register is executed, I don't receive a notification that has a registration ID (after pushNotification.register, ecb was not fired). But success handler was fired. One strange thing is success handler is also fired when I turn off every network (Wifi, mobile internet). So I tried it on another phone (friend's). Then it works well.

What happened in my phone? I searched this issue last few days, but I couldn't find any helpful docs. Is there anybody who has same problem?

    var pushNotification;
    document.addEventListener("deviceready", function(){
        pushNotification=window.plugins.pushNotification;
        console.log('Device Ready!!');
        register();
    });
    function register() {
        console.log('registering...');
        pushNotification.register(
            successHandler,
            errorHandler,
            {
                "senderID":"1234567890", // (temporary)
                "ecb":"onNotification"
            }
        );
    }

    function onNotification(e) {
        console.log('======onNotification======');
        console.log('type of notification:'+e.event);
        switch(e.event) {
            case 'registered':
                if(e.regid.length>0) {
                    $("#status").append('<li>regid:'+e.regid+'</li>');
                    console.log('regid:'+e.regid);
                }
            break;

            case 'message':
                if(e.foreground) {
                    console.log('inline message');
                } else {
                    if(e.coldstart) {
                        console.log('coldstart message');
                    } else {
                        console.log('background message');
                    }
                }
                console.log('message:'+e.payload.message);
                console.log('msgcnt:'+e.payload.msgcnt);
            break;

            case 'error':
                $("#status").append('<li>error:'+e.msg);
            break;
        }
    }
    function successHandler(result) {
        console.log('success; result:'+result);
    }
    function errorHandler(error) {
        console.log('error; error:'+error);
    }
Ajoy
  • 1,838
  • 3
  • 30
  • 57
  • I'm in the exact same position. I've tried rebooting my phone or removing/reinstalling my app as suggested [here](https://github.com/phonegap-build/PushPlugin/issues/176) but nothing has worked so far. – maxdec Jul 02 '14 at 16:52
  • same thing!! https://github.com/phonegap-build/PushPlugin/issues/395 – mariomol Nov 11 '14 at 00:56
  • If the issue was solved, please add your answer. – Ajoy Apr 08 '15 at 04:45

0 Answers0