2014-01-17 6 views
1

это мой код. Когда мое приложение будет убито и перезапущено в push-уведомлении, оно должно перенаправляться должным образом, однако оно никогда не переходит в pushNotification.notificationCallback = function(event). Не имеет понятия, почему.PushWoosh уведомлениеCallback не стрельба

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); 
         } 
        }; 

ответ

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

Смежные вопросы