iOS — Testing push notifications

Muhammad Zeeshan
4 min readJun 13, 2023

--

Recently Apple has introduces new debugging tools for testing push notifications. In this article we will go through newly introduced tools for testing push notifications. Previously it is very painful to debug push notifications and we have to go through a checklist that needs to be cross checked in case if notifications are not delivered at the device end.

All New Push notification debugging tool

First of all navigate to CloudKit Console and click on Push notifications card.

Select the relevant app and click on the Create New Notification

Fill the form as required and click on send button.

Copy the device token from the func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)

Make sure you allow for notifications permission when prompted otherwise the above function will not be called.

If everything goes well you will receive the push notification on device.

In case if you didn’t received the notification you need to note down the apns-unique-idand navigate to the delivery logs and look for potential error message against the apns-unique-id. In the above case i have received the notification the logs look like the following.

Next we can simulate the error case as explained in the WWDC video by enabling low power mode on the device. Goto SettingsBattery and turn on the low power mode.

Next try to send a new notification to the same device token again and you will see that notification will not be received at the device end. When you read the logs it will give you more insight that why push notification is not received at the device end?

Make sure that the device is not connected to the power source. I have noticed that if the device is connected to the power source the notification will get received.

Old school checklist

  • Provisioning Profiles: Ensure that the necessary provisioning profiles are correctly set up and associated with the app’s bundle identifier. More over the profile is not revoked on expired.
  • App Configuration: Verify that the app is correctly configured to receive push notifications by checking the entitlements and capabilities in Xcode.
  • Notification Permissions: Test the app’s behaviour when the user grants or denies permission to receive push notifications. Verify that the appropriate dialog prompts are displayed.
  • Payload Format: Cross check the push notification payloads, including text, badges, sounds, and custom data. Verify that the app handles each type correctly.
  • Payload Size: Test the behaviour of push notifications with various payload sizes, ensuring the app can handle both small and large payloads.
  • Silent Notifications: Test the app’s response to silent notifications, which are delivered to the device without displaying any UI elements. Verify that the app processes the notification correctly in the background.
  • Background and Foreground Handling: Test the app’s behaviour when a push notification is received while the app is running in the foreground and background. Verify that the appropriate actions are taken, such as displaying an alert or updating the app’s UI.
  • Certificate: In case if you are using certificates for push notification make sure that the in use certificate is not expired or revoked.
  • Network Conditions: Test push notifications under different network conditions, including low or intermittent connectivity, to ensure that the app can receive notifications reliably.
  • Low power mode: Make sure that the device isn’t in the low power mode.

With the new debugging tools it will now easy to debug push notifications related issues. Thanks to Apple 😎.

--

--

Muhammad Zeeshan
Muhammad Zeeshan

No responses yet