Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device Token registering fine in development, but not production

I am creating a PhoneGap application for iOS and Android. I have gotten Android to work perfectly fine, but am having trouble switching from Development to Production in iOS. A device token is not being registered for the device with a production adHoc build. I have exhausted every thing I could think of. Here is what I have done so far:

  1. Deleted all certificates and provisiong profiles on my computer to try and start over fresh.
  2. Enabled production APNS on my application specific app id (not wildcard app id) and imported it into my keychain.
  3. Created new production provisioning profile for adHoc distribution using the production ssl certificate and correct app id. Checked to make sure aps-environment was set in the provision profile.
  4. Imported the new provisioning profile and set the application to use the correct one in my build settings for project and targets.
  5. Exported the p12 file for importing into UA.
  6. Deleted and created a new application on UA set for production use. Uploaded the p12 file and turned on Push Debug mode.
  7. Made sure the AirshipConfig.plist had the correct production keys and was set APP_STORE_OR_AD_HOC_BUILD to YES.
  8. Archived the app and exported it for adhoc distribution and loaded it onto the phone via itunes.

When I run the app for the first time on the device with everything completely redone. This is what I get in the console:

Mon Sep 17 12:48:00 unknown XXXXXXXXX[5039] Warning: Multi-tasking - Device: NO, App: YES

Mon Sep 17 12:48:05 unknown XXXXXXXXX[5039] Warning: Reachability Flag Status: -R -----l- networkStatusForFlags
Mon Sep 17 12:48:06 unknown XXXXXXXXX[5039] Warning: [M] = -[UAPush updateRegistration] [Line 583] Checking registration state
Mon Sep 17 12:48:06 unknown XXXXXXXXX[5039] Warning: [M] = -[UAUser listenForDeviceTokenReg] [Line 969] ListenForDeviceTokenReg
Mon Sep 17 12:48:06 unknown XXXXXXXXX[5039] Warning: [M] = -[UAUser retrieveRequestSucceeded:] [Line 911] User retrieved: 200:{
"user_id" : "XX-XXXXXXXXXXXXXXXXX",
"user_url" : "https://device-api.urbanairship.com/api/user/XX-XXXXXXXXXXXXXXXXX/",
"tags" : [ ],
"device_tokens" : [ ],
"device_pins" : [ ],
"apids" : [ ],
"has_active_subscription" : false,
"subscriptions" : [ ],
"ua_device_ids" : [ "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" ],
"badge" : 0,
"server_time" : "2012-09-17 17:48:02"
}
Mon Sep 17 12:48:06 unknown XXXXXXXXX[5039] Warning: [M] = -[UAUser updateDefaultDeviceToken] [Line 1016] Updating device token
Mon Sep 17 12:48:06 unknown XXXXXXXXX[5039] Warning: [M] = -[UAUser updateDefaultDeviceToken] [Line 1021] Skipping device token update: no token, already up to date, or user is being updated.

Mon Sep 17 12:48:21 unknown XXXXXXXXX[5039] Warning: [M] = +[UAKeychainUtils getDeviceID] [Line 269] Retrieved device id info from keychain.
Mon Sep 17 12:48:21 unknown XXXXXXXXX[5039] Warning: [M] = +[UAKeychainUtils getDeviceID] [Line 273] Device ID result is not nil.
Mon Sep 17 12:48:21 unknown XXXXXXXXX[5039] Warning: [M] = +[UAKeychainUtils getDeviceID] [Line 282] Loaded Device ID: XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Mon Sep 17 12:48:21 unknown XXXXXXXXX[5039] Warning: [M] = +[UAKeychainUtils getDeviceID] [Line 283] Loaded Model Name: iPhone1,2
Mon Sep 17 12:48:21 unknown XXXXXXXXX[5039] Warning: [M] = -[UAAnalytics requestDidSucceed:response:responseData:] [Line 467] Analytics data sent successfully. Status: 200

I blanked out the ID numbers and app name.

This message above "Skipping device token update: no token, already up to date, or user is being updated." seems weird to me. This is a newly created UA Application with new keys and everything. I also loaded it up with my development profile, keys and everything and it works just fine. It just does not register device tokens in a production run.

Any help is appreciated. I have checked every setting and as far as I can tell all of my profiles, keys, entitlements are all set properly. I am running on WiFi since the phone I am using is just a test phone that doesn't have active carrier service.

like image 285
davesters81 Avatar asked Nov 03 '22 15:11

davesters81


1 Answers

I've now solved this problem twice, I think, though I'm not 100% sure what the core problem is - i think there's an issue with how you test it.

Try to get the UA Push Sample app to work:

  • Download the UA PushSample app.
  • update the AirshipConfig.plist file with your app/secret combo
  • update the build with the right bundle ID, provisioning profile, etc.
  • delete your app from your device (they'll clash when you try to build the PushSample app if it's still on there with the same bundle identifier.
  • compile and run the push sample app.
  • look for a token in the log, and also check the UA dashboard (for # tokens, or just send a broadcast alert).

Do you still have the same issue? In my case, both times, it went away and was successfully able to register the token. I think that for some reason the mis-configured certs / provisioning profiles prevented the token from being created properly. When I fixed them - it was too late, because the UA library thought it had registered and was therefore skipping over that part. This line in the log is what made me suspect:

Checking registration on app foreground disabled on app initialization

Now 2 for 2, when I put the correct certs/bundle/provisioning profile in the clean PushSample app, it worked properly

like image 161
Alexander Shartsis Avatar answered Nov 12 '22 10:11

Alexander Shartsis