这是我的密码。当我的应用程序被杀死,并在推送通知中重新启动时,它应该正确地重定向,但是它从来没有真正进入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);
}
};发布于 2014-01-20 16:58:25
实际上,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
https://stackoverflow.com/questions/21196259
复制相似问题