1

これが私のコードです。私のアプリが強制終了され、プッシュ通知で再起動されると、適切にリダイレクトされるはずですが、実際には決して入り 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);
                        }
                    };
4

1 に答える 1

0

実際、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

于 2014-01-20T16:58:25.323 に答える