使用Urban Airship&Phonegap,无法注册设备:"设备令牌为零"

Rya*_*tin 4 urbanairship.com ios cordova

从git hub(https://github.com/urbanairship/phonegap-ua-push)上的最新示例,以及Phonegap/Cordova最新版v2.3.0的全新版本,我们在iOS注册设备时遇到了麻烦UA.在我们更新到最新版之前,我们没有问题.我们正在注册这样的设备:

function on_reg(error, pushID) {
    console.log("UA Registration complete.")
}

push = window.pushNotification
push.registerEvent('registration', on_reg)
Run Code Online (Sandbox Code Playgroud)

但每当我们调用该代码时,我们会收到一条错误消息" 设备令牌为零.稍后将尝试注册 ".除非从未发生过.

这是日志:

2013-01-09 17:38:29.378分组[271:907] [D] - [UAPush updateRegistration] [第589行]检查注册状态

2013-01-09 17:38:29.380分组[271:907] [D] - [UAPush updateRegistration] [第609行]设备令牌为零.稍后将尝试注册

2013-01-09 17:38:29.744分组[271:907] [D] + [UAKeychainUtils getDeviceID] [第275行]从钥匙串中检索设备ID信息.

2013-01-09 17:38:29.745分组[271:907] [D] + [UAKeychainUtils getDeviceID] [第279行]设备ID结果不是nil.

2013-01-09 17:38:29.746分组[271:907] [D] + [UAKeychainUtils getDeviceID] [第288行]已加载设备ID:C1E75722-ED34-4513-BBA5-CB9EDEBBD117

2013-01-09 17:38:29.747分组[271:907] [D] + [UAKeychainUtils getDeviceID] [第289行]已加载型号名称:iPhone4,1

2013-01-09 17:38:32.724分组[271:907] [D] - [UAAnalytics requestDidSucceed:response:responseData:] [Line 461] Google Analytics数据已成功发送.状态:200

我们做错了什么?

Rya*_*tin 7

我将此错误跟踪到最新版本的PhoneGap中所做的更改:

对于iOS,device.platform用于返回"iPhone","iPad"或"iPod Touch" - 现在它返回(正确)"iOS".

这与PushNotification.js模块冲突,返回错误信息:

// Registration

PushNotification.prototype.registerForNotificationTypes = function (types, callback) {
if(device.platform == "iPhone" || device.platform == "iPad" || device.platform == "iPod touch") {
this.call_native(callback, "registerForNotificationTypes", [types])
}
}
Run Code Online (Sandbox Code Playgroud)

将其更改为device.platform =="iOS"可解决此问题.

Urban Airship,如果你想更新你的git,访问https://github.com/urbanairship/phonegap-ua-push/blob/master/ios-sample/www/lib/PushNotification.js我相信很多人会很感激它!