我在Phonegap / Cordova 2.1上使用iOS PushNotification插件(https://github.com/phonegap/phonegap-plugins/tree/master/iOS/PushNotification)。
“推送通知”事件工作正常,相关的事件处理程序触发就好了。但是,我有一些意想不到的结果: 启动应用程序时会调用getPendingNotifications,但是......
创建此问题时,我发现此帖子: PushNotification in iOs and Application icon is clicked
但我真的无法想象这应该是预期的行为。
然而,这是我的getPending方法,它在简历和在线中被调用:
getPending: function() {
app.pushNotification = window.plugins.pushNotification;
app.pushNotification.getPendingNotifications(function(notifications) {
console.log('PushNotification: getPending ' + JSON.stringify([notifications]));
if(notifications) {
$.each(notifications, function(i, el) {
if(el[0].page && el[0].aps.alert) {
app.pushContent = el[0].page;
navigator.notification.alert(
el[0].aps.alert, // message
app.redirectPushcontent, // callback
'Push it', // title
'real good' // buttonName
);
}
});
}
});
},
更新 我使用了一个名为getIconBadgeNumber的PushNotification PlugIn的新方法。 如果BadgeNumber> 0,则必须有新的通知。我无法收到PushNotification消息,但我可以做其他事情。这是某事......