Using Urban Airship & Phonegap cannot register the device: "Device marker is zero",

From the latest example on the git hub (https://github.com/urbanairship/phonegap-ua-push), with the new new version of Phonegap / Cordova version v2.3.0, we have problems with iOS registering a device with UA. We had no problems until we updated to the last. We register the device as follows:

function on_reg(error, pushID) { console.log("UA Registration complete.") } push = window.pushNotification push.registerEvent('registration', on_reg) 

But every time we call this code, we get an error saying that "the device token is zero. Registration will be undertaken later ." Except that never happens.

Here is the log:

2013-01-09 17: 38: 29.378 Grouped [271: 907] [D] - [UAPush updateRegistration] [Line 589] Checking the registration status

2013-01-09 17: 38: 29.380 Grouped [271: 907] [D] - [UAPush updateRegistration] [Line 609] The device marker is zero. Registration will try at a later time.

2013-01-09 17: 38: 29.744 Grouped [271: 907] [D] + [UAKeychainUtils getDeviceID] [Line 275] Received information about the device identifier from the remote control.

2013-01-09 17: 38: 29.745 Grouped [271: 907] [D] + [UAKeychainUtils getDeviceID] [Line 279] The result of the device identifier is not zero.

2013-01-09 17: 38: 29.746 Grouped [271: 907] [D] + [UAKeychainUtils getDeviceID] [Line 288] Uploaded device identifier: C1E75722-ED34-4513-BBA5-CB9EDEBBD117

2013-01-09 17: 38: 29.747 Grouped [271: 907] [D] + [UAKeychainUtils getDeviceID] [Line 289] Uploaded Model Name: iPhone4,1

2013-01-09 17: 38: 32.724 Grouped [271: 907] [D] - [UAAnalytics requestDidSucceed: response: responseData:] [Line 461] The analytics data was sent successfully. Status: 200

What are we doing wrong?

+4
source share
1 answer

I tracked this error until the change made to the latest version of PhoneGap:

For iOS, device.platform is used to return "iPhone", "iPad" or "iPod Touch" - now it returns (correctly) "iOS".

This contradicted the PushNotification.js module, returning false information:

 // Registration PushNotification.prototype.registerForNotificationTypes = function (types, callback) { if(device.platform == "iPhone" || device.platform == "iPad" || device.platform == "iPod touch") { this.call_native(callback, "registerForNotificationTypes", [types]) } } 

Changing this parameter to device.platform == "iOS" fixes the problem.

Urban Airship, if you want to update your git at https://github.com/urbanairship/phonegap-ua-push/blob/master/ios-sample/www/lib/PushNotification.js I'm sure many people will appreciate it!

+7
source

All Articles