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
- Devices and Simulator window opens up, 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”
- 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!
PS: If you liked this, click the 👏 below. I notice each one and I’m grateful for every one of them.
For more musings about programming, follow me so you’ll get notified when I write new posts.
Originally published at www.gitshah.com on August 31, 2018.