【问题标题】:Multiple push notification present in the status bar in android when the second is touched others vanish当第二个被触摸时,android的状态栏中出现多个推送通知其他人消失
【发布时间】:2015-06-16 16:38:43
【问题描述】:

我在 cordova android 应用程序中使用 Notification GCM。 当应用程序在后台运行并收到通知时 它显示在设备的状态栏中。 当此状态栏中显示两个以上通知时,我点击第一个通知(显示在状态栏中),应用程序打开并显示通知消息,当我点击第二个通知时,所有剩余通知(在状态栏)消失。 在这个函数中,当我点击通知时,部分(!e.foreground)运行。

function onNotificationGCM(e) {

  switch( e.event )
   {
    case 'message':


        if (e.foreground)
        {   
            // playAudio('http://oringz.com/oringz-uploads/sounds-1068-the-calling.mp3');
            navigator.notification.beep(1);
            msgNotification(e.payload.message);
            $("#toastContainer").dxToast('instance').show();
            var notif={message:e.payload.message};
            popovernotifListe.push(notif);
            nbrnotif(nbrnotif()+1);

        }
        else if (!e.foreground)
        {

             if (e.coldstart) {
                    console.log("App was not running and user clicked on notification");
            } else {
                console.log("App was running and user clicked on notification");
            }
            msgNotification(e.payload.message);
            $("#toastContainer").dxToast('instance').show();
            nbrnotif(nbrnotif()+1);
            var notif={message:e.payload.message};
            popovernotifListe.push(notif);

        }
        break;

        case 'error':
          console.log('GCM error = '+e.msg);
        break;

        default:
          console.log('An unknown GCM event has occurred');
        break;
}

}

【问题讨论】:

  • 我不会对此表示反对,但您真的应该改进您的问题。你希望发生什么?你能给我们看一些代码吗?
  • 我做到了(用代码更好地解释)
  • answer 有帮助吗?
  • 谢谢你的帮助,但这并不能解决问题,当我触摸状态栏中的第二个通知时,(当我有很多时),其他的在状态栏中消失了

标签: android cordova google-cloud-messaging phonegap-pushplugin


【解决方案1】:

如果通知 ID 不是从您的服务器发送的,则会使用 ID 0 创建每个通知。

要解决此问题,您必须为您创建的每个通知设置notification ID。您可以通过从服务器发送参数notID 来设置通知ID,每个通知将用于create a notification

【讨论】:

    猜你喜欢
    • 2015-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-21
    相关资源
    最近更新 更多