【问题标题】:tokenHandler() doesn't fire when you open app (ios, PushPlugin), have to minimize the app then reopen it to fire event打开应用程序(ios,PushPlugin)时 tokenHandler() 不会触发,必须最小化应用程序然后重新打开它以触发事件
【发布时间】: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


    【解决方案1】:

    你试过了吗:

    document.addEventListener('deviceready', onDeviceReadyPush, FALSE);

    【讨论】:

    • 感谢您的意见,我确实尝试过,但还是不行。我最终将所有内容更新到最新版本,它开始按预期工作。我想我使用了错误的科尔多瓦文件。
    【解决方案2】:

    我使用了错误的cordova 文件。在将所有内容更新到当时的最新版本后,它开始按预期工作。

    【讨论】:

    • 您能详细解释一下吗?我有同样的问题。刚升级到Cordova 3.1.0-0.2.0,也更新了PushPlugin,现在iOS不调用token handler函数了,但是等价的Android就可以了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    • 2016-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多