【发布时间】:2013-01-30 18:07:25
【问题描述】:
我正在尝试为 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 事件。
请帮忙,这两天我一直在尝试所有我能想到的东西,我快疯了。
【问题讨论】:
标签: jquery ios cordova push-notification