How to Retrieve Device Information from Urban Airship

Urban Airship provides several API endpoints that allow for retrieval of device identifiers and information associated with those devices.

 

iOS

Urban Airship Documentation on Device Listing API - GET /api/device_tokens/

The device listing will include:

  • Tags
  • Aliases
  • Active/inactive
  • APNS device token

This request will return 1000 devices per call. Multiple calls may need to made to retrieve all devices. A total device count and next page URL will be included with each request.

The total number of devices can also be found with this API call - GET /api/device_tokens/count/

 

Android

Urban Airship Documentation on APID listing API - GET /api/apids/

The APID listing will include:

  • APID (Urban Airship generated device identifier)
  • Tags
  • Aliases
  • Created Date
  • Active/inactive
  • C2DM Registration ID (if applicable)

This request will return 1000 devices per call. Multiple calls may need to made to retrieve all devices. A total device count and next page URL will be included with each request.

 

Individual Device Lookup

You can get more information about a device by performing an individual device lookup. Here, in addition to the above information, you can find:

  • Last Registration Date
  • Badge Value (iOS)
  • Quiet Time information (iOS)
  • Time Zone (iOS)
  • GCM Registration ID (Android)

While there is more information here, a separate API call must be made for each device you wish to get information from.

 

Pagination

If your application has more that 1000 devices registered under it's app key, the device listing APIs will only return a page of 1000 on the first call. This response will also include a URL for the next page:

"next_page" : "https://go.urbanairship.com/api/device_tokens/?limit=1000&start=026C556XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX431CF"

You will want to then make another cURL request with that full URL in place of the normal API endpoint URL.

curl -X GET -u "<app_key>:<master_secret>" https://go.urbanairship.com/api/device_tokens/?limit=1000&start=026C556XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX431CF

This will return the next page of results and another next_page URL if appropriate. You can continue on like this until all device tokens have been received.

 

Related Content: