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

时间:2013-01-10 02:04:07

标签: ios cordova urbanairship.com

来自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)

但每次我们调用该代码时,都会收到错误消息“设备令牌为零。稍后将尝试注册”。除非从未发生过。

这是日志:

  

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] Analytics数据   成功发送。状态:200

我们做错了什么?

1 个答案:

答案 0 :(得分:7)

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

  

对于iOS,device.platform用于返回“iPhone”,“iPad”或“iPod”   触摸“ - 现在它返回(正确)”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])
}
}

将此更改为 device.platform ==“iOS”可解决此问题。

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

相关问题