了解应用在后台时是否收到通知

时间:2014-12-24 01:26:00

标签: cordova phonegap-pushplugin

当我将我的cordova应用程序带到前台时,我想检查是否收到通知,而应用程序在后台。 有没有办法捕捉待处理的通知?有没有人知道如何实现这一目标?

我从以下开始,但它不起作用:

document.addEventListener("resume", resume, false);

function resume(){
    var pushNotification = window.plugins.pushNotification;
    pushNotification.getPendingNotifications(function(notifications) {
            alert(JSON.stringify(notifications));
    });
};

我使用此插件:https://github.com/phonegap-build/PushPlugin并显示通知。

1 个答案:

答案 0 :(得分:2)

我认为PushPlugin没有getPendingNotifications。默认的插件行为是,如果它在后台接收通知,它将在状态栏中创建通知。如果用户单击该通知,则应用程序在前台时将收到该消息。