我正在尝试为 iOS 实施新的 PhoneGap PushPlugin,但无法弄清楚为什么我会遇到这个问题。
应用加载时,成功调用 OnDeviceReadyPush 函数:
var pushNotification;
function onDeviceReadyPush() {
$("#app-status-ul").append('<li>deviceready event received</li>');
pushNotification = window.plugins.pushNotification;
if (device.platform == 'android' || device.platform == 'Android') {
pushNotification.register(successHandler, errorHandler, { "senderID": "661780372179", "ecb": "onNotificationGCM" });
} else {
pushNotification.register(tokenHandler, errorHandler, { "badge": "true", "sound": "true", "alert": "true", "ecb": "onNotificationAPN" });
}
}
document.addEventListener('deviceready', onDeviceReadyPush, true);
假设要启动 tokenHandler 函数:
function tokenHandler(result) {
$("#app-status-ul").append('<li>token: ' + result + '</li>');
// Your iOS push server needs to know the token before it can push to this device
// here is where you might want to send it the token for later use.
$.get("", { "deviceid": result}, processResult);
function processResult(data, textStatus) {
alert(data);
}
}
直到我最小化应用程序然后再回到它,它才起作用。然后它触发 tokenHandler 事件。
请帮忙,我一直在看这个,尝试了我能想到的一切两天,我快疯了。