【问题标题】:PushWoosh notificationCallback not firingPushWoosh 通知回调未触发
【发布时间】:2014-01-17 21:30:05
【问题描述】:

这是我的代码。当我的应用程序被杀死并在推送通知上重新启动时,它应该正确重定向,但它实际上从未进入 pushNotification.notificationCallback = function(event) 不知道为什么。

function initPushWoosh() {
                try {
                    checkNetworkConnection();

                    if(!window.plugins) {
                        wodifyRedirect('unknown-' + device.token);
                        return;
                    }

                    var pushNotification = window.plugins.pushNotification;
                    pushNotification.notificationCallback = function(event) {
                        var notificationId = 0;
                        if(event.u && event.u.custom) {
                            notificationId = event.u.custom;
                        } else if(event.u) {
                            notificationId = JSON.parse(event.u).custom;
                        } else if(event.custom && event.custom.custom) {
                            notificationId = event.custom.custom;
                        } else if(event.custom) { 
                            notificationId = JSON.parse(event.custom).custom;
                        }

                        if(event.onStart && notificationId != 0) {
                            navigateToNotifications(notificationId, device.uuid);
                        }
                    };

【问题讨论】:

    标签: javascript ios cordova push-notification pushwoosh


    【解决方案1】:

    其实Pushwoosh定义了自己的通知回调:

    PushNotification.prototype.notificationCallback = function(notification) {
                var ev = document.createEvent('HTMLEvents');
                ev.notification = notification;
                ev.initEvent('push-notification', true, true, arguments);
                document.dispatchEvent(ev);
        };
    

    这可以通过以下方式处理:

    document.addEventListener('push-notification', function(event) {
    

    在此处查看 Pushwoosh 示例应用:

    https://github.com/shaders/phonegap-3-sample-app/tree/master/www

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多