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);
}