How to debug iOS Push Notifications

Francesco Pretelli
2 min readNov 24, 2016

I noticed there are a lot of guides on how to set up push notifications but I couldn’t find one explaining properly how to debug them.

It’s actually pretty easy and quick, I’ll assume you already have created and set up your APNS Certificate for development (if not, you can follow this guide from OneSignal).

  • Download Pusher, an open source app to send push notifications
  • In your AppDelegate file, be sure to have added the following function:
    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)
  • You will need to read the deviceToken variable, to do that you can use the following snippet:
    let deviceTokenString = (deviceToken.description as NSString).stringByTrimmingCharactersInSet(characterSet).stringByReplacingOccurrencesOfString(“ “, withString: “”) as String
  • Run your project on a device (simulators don’t support push notifications)
  • Copy the printed out token in the debug console, if there is no token it means your push notification are not set up properly.
  • Open the Pusher app downloaded in point 1:
Pusher App
  • Select your push certificate and paste the token in the text box
  • If the app is in foreground, tap the device’s home button
  • Push!

If you are debugging your project from XCode, you have to enable “Should use sandbox environment”.

You can now test with different payload and debug directly in XCode without the need for a notification service.



Francesco Pretelli

Engineering Manager - Tokyo. I write about everything, from tech to daily stuff.