Friday, August 31, 2018

How to find APNS Device Token of a Production iOS app

I wanted to test out the look and feel of a push notification on the production iOS app. For that, we needed to know device token of my device.

The Problem

Quick googling suggests that, we can get the device token from the app delegate callback method. However this method doesn't work for production apps. So how do we get the device token of a production iOS app?

The Solution

The solution is pretty straightforward and extremely low tech :D. We could get the device token from XCode using the following steps:

  • Connect your device with the Mac
  • Open XCode, click on Window -> Devices and Simulators
  • Open Devices and Simulators
  • Devices and Simulator window opens up, click on "Open Console"
  • Click on Open Console
  • New and shiny device console opens up
  • Launch the app and accept the popup to receive notifications.
  • Now on the device console search for "Request per-app token with token identifier"
  • Device Console with Push Token
  • You should get the device token which is in the format "4D2338E0-1D8F-490A-9C8E-F5A4FEA2CFFF"
Just use the device token with any push notification sending service to send the push notification to your device!
Have some Fun!