2013-01-10 50 views
4

从git hub上的最新示例(https://github.com/urbanairship/phonegap-ua-push),以一个闪亮的新Phonegap/Cordova最新v2.3.0版本的构建,我们在iOS上注册带有UA的设备时遇到问题。我们没有问题,直到我们更新到最新。我们正在注册设备是这样的:使用Urban Airship和Phonegap,无法注册设备:“设备令牌为零”

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

push = window.pushNotification 
push.registerEvent('registration', on_reg) 

但每次我们调用的代码时,我们得到一个错误,指出“设备令牌是零报名将在稍后的时间尝试。”除此之外从未发生过。

这里是日志:

2013年1月9日17:38:29.378分组[271:907] [d] - [UAPush updateRegistration] [589线]检查注册状态

2013-01-09 17:38:29.380分组[271:907] [D] - [UAPush updateRegistration] [Line 609]设备令牌为零。注册将 在以后的时间尝试

2013年1月9日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结果不为零。

2013年1月9日17:38:29.746分组[271:907] [d] + [UAKeychainUtils getDeviceID] [线路288]已装入设备ID: C1E75722-ED34-4513-BBA5-CB9EDEBBD117

2013年1月9日17:38:29.747分组[271:907] [d] + [UAKeychainUtils getDeviceID] [289线]加载的模型名称:iPhone4,1

2013年1月9日17时38分: 32.724分组[271:907] [D] - [UAAnalytics requestDidSucceed:response:responseData:] [Line 461]分析数据 已成功发送。状态:200

我们做错了什么?

回答

7

我跟踪这个bug下来到在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版”解决了这个问题。

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

+0

伙计...... 3小时后......谢谢。 – Nate

+0

嗨,你能帮我使用iOS中的urbanairship在phonegap中设置推送通知吗? –

相关问题