onNotificationGCM: function (e) {
// alert('onNotificationGCM');
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
console.log("Regid " + e.regid);
var regID=e.regid;
//Call postGCMRegistration inthe hosLib.js Class to send RegID to Server
postGCMRegistration(regID);
// alert('registration id = '+regID);
}
break;
case 'message':
if (e.foreground) {
// this is the actual push notification. its format depends on the data model from the push server
if (e.message == "ignitionON") {
// alert("ignitionON");
ignitionON();
}
if (e.message == "movementON") {
// alert("movementON");
MovementStarted();
}
if (e.message == "ignitionOFF") {
// alert("ignitionOFF");
ignitionOFF();
}
}
//alert('message = '+e.message+' msgcnt = '+e.msgcnt);
break;
case 'error':
//alert('GCM error = '+e.msg);
break;
default:
// alert('An unknown GCM event has occurred');
break;
}
},
};
这是我在Android应用中设置推送通知的代码,它工作正常。
我唯一不希望展示的是通知栏上收到的推送消息,当我的屏幕被锁定或应用程序未打开时,该消息会保留在通知栏上(但它不会显示在通知栏上) ; t如果应用程序在主屏幕上打开,则在通知栏中显示任何内容。)
任何解决方案?