How to retrieve device tokens

There are two ways to retrieve device tokens: Application Code/Device Logs and Persistent Connection Logging.

Through Application Code:

[UAirship setLogging:YES] can be called during application runs which will log out information, including the device token, or didFailToRegister errors.

For debugging, a good place to grab your device_token is in didRegisterForRemoteNotificationsWithDeviceToken.

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    UA_LTRACE(@"APNS device token: %@", deviceToken);

    // Updates the device token and registers the token with UA. This won't occur until
    // push is enabled if the outlined process is followed. This call is required.
    [[UAPush shared] registerDeviceToken:deviceToken];
}

 

Through Persistent Connection Logging:

For devices running iOS 7 or later, every app on every device will now have its own Device Token rather than a shared device token across all apps.  

We have provided the below instruction set to assist in installing the PersistentConnectionLogging profile onto a device and using that tool to retrieve device tokens.

The PersistentConnectionLoggingProfile itself is very small, but the logs it generates can be any size.  If the test device is for personal use, after you have completed investigation, you may want to consider removing the logging profile to conserve space.

 

  1. ​Start here:

  2. At the top right of the page, there is a link to download a 'Companion File':
     Screen_Shot_2015-02-25_at_2.17.57_PM.png
  3. Click that link to download the
    'tn2265_PersistentConnectionLogging.zip'  file.
  4. Unzip the 'tn2265_PersistentConnectionLogging.zip'  file which will create a “PersistentConnectionLogging.mobileconfig” file.
  5. Email the “PersistentConnectionLogging.mobileconfig” file to your device as an attachment.
  6. Tap the the “PersistentConnectionLogging.mobileconfig” file from the email to install.
  7. Enter your Passcode when prompted.  
  8. Restart the device.

Install either Xcode or iPhone Configuration Utility

  1. Install either Xcode (typically around 2GB) or the Apple Configurator utility 
     - Xcode requires a Developer account
  2. Open either Xcode's "Devices" or the iPhone Configuration Utility
  3. Highlight your device name on the left, and go to the Console tab.
  4. Open the app you wish to retrieve the Device Token for
  5. Watch for data approximating the below:

    Untitled.png

    Or it may show as the following: (remove spaces for the device token)

    UntitledV2.png

  6. Copy the above, remove spaces if present.   This is your device token.

 

Related Content: