How to test your Push Notifications implementation on iOS
What are Push Notifications?
Push notifications are automated messages sent out by app owners to the app users when the application is not open. Usually short, a notification can reach an audience anywhere and anytime. This means it’s doubly important that they work as they’re supposed to and that the app owners build a flow of notifications that makes sense for the user. Push notifications generate high engagement with the userbase, but users can also opt out of receiving them if they find them bothersome.
Test push notifications like PRO 😎
Let’s assume you’ve already implemented and configured the push notifications functionality for your project. Now you’re asking yourself if everything you’ve put together is done right.
You can find all sorts of similar information over the internet. I’m bringing all the tips and tricks together here and I hope you’ll find it useful and to the point.
Let’s get started
In this article, I’m going to show you how to receive a push notification without bothering your backend developer teammate.
On iOS projects, there are two ways to establish communication with APNS servers: you do it on your server or by using Firebase Messaging.
Test push notifications by using a device token
Before testing, check the following conditions apply to you:
- You’ve implemented push notifications on your project.
- You have the p8 Key or p12 Certificate.
All good? Great, let’s get started.
- Run the app on a physical device and copy your device token as a string.
2. Open Push Notifications Tester and select the corresponding Authentication tab that fits your case.
3. Upload the file and complete the authentication:
- for p12 Certificate insert passphrase
- for p8 Key add key id and team id
4. Paste your device token value and configure Notification JSON
5. Hit the send button 🤞
Test push notifications by using fcmToken
If you’ve implemented Firebase and Firebase Messaging integration correctly, you’ll also need to upload the p8 Key or p12 Certificate to your Firebase project’s console in order to test push notifications. Once you’ve done this, you can get started.
- Go to your project’s firebase console and copy the Cloud Messaging Server key. (Project settings → Cloud Messaging). If you don’t have one, create a new server key.
- Run the app on a physical device and copy your fcmToken.
- Open your API/REST Development Tool. I use Postman.
4. Setup the API call as follow:
- URL and method: POST — https://fcm.googleapis.com/fcm/send
- HTPP headers:
- Body
5. Send push notification 🤞
For more info about Firebase Messaging HTTP syntax, you can find the resources here.
If the push notifications you’ve sent out don’t come through, you’ll need to go back to your codebase and find the bug that’s causing the error.
Happy testing! 👨💻