屏幕锁定时,PhoneGap推送通知会在通知栏中显示消息

时间:2015-08-06 18:51:34

标签: javascript google-cloud-messaging phonegap-pushplugin

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如果应用程序在主屏幕上打开,则在通知栏中显示任何内容。)

任何解决方案?

0 个答案:

没有答案
相关问题