【问题标题】:Tapping on one notification clears all the other notification from the same app - Phonegap Plugin Push点击一个通知会清除来自同一应用程序的所有其他通知 - Phonegap Plugin Push
【发布时间】:2016-06-22 12:24:07
【问题描述】:

我已经使用这个plugin 实现了推送。

现在,当我有多个具有不同 notId 的通知时,我点击其中一个时,会调用事件处理程序,但其他通知会从通知托盘中消失。

这个特定问题似乎在同一插件的旧版本的Github 页面上打开。

以下是我的代码:

  var push = PushNotification.init({
        "android": {"senderID": "XXXXXXX" ,"icon": "ic_transey1",
            "iconColor": "grey"},
        "ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {}
    });

    push.on('registration', function (data) {
        console.log('device token ',data.registrationId);
        window.localStorage.setItem("UserDeviceID", data.registrationId);
    });

    push.on('error', function (e) {
        console.log(e);
    });

    push.on('notification', function (data) {
        console.log('notification event');
        navigator.notification.confirm(
                data.message,
                function (buttonIndex) {
                    onConfirm(buttonIndex, data);
                },
                data.title,
                ['Dismiss','Ok']
        );

/* at first I thought setApplicationIconBadgeNumber is causing the issue, 
but commenting the below code didnt help either */

        /*push.setApplicationIconBadgeNumber(function() {
            console.log('success in clearin');
        }, function() {
            console.log('error');
        }, 0);*/
    });

我尝试在底部评论setApplicationIconBadgeNumber,但没有帮助。

对此有任何修复/解决方法吗?

【问题讨论】:

标签: android cordova phonegap-plugins phonegap-pushplugin


【解决方案1】:

这是因为 clearNotifications 选项默认为 Android 的 true,这会清除所有通知。 对于 Android,将其设置为 clearNotifications:false,它将正常工作。

https://github.com/phonegap/phonegap-plugin-push/issues/1015 https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多