Introduction:
Enabling push notifications in an iOS App is not a typical task. But sending push notifications to iOS device requires server side implementation which interacts with APNS to send push notification to an iOS device. Here’s an another alternative for sending push notifications to iOS device is using Firebase Cloud Messaging (FCM). Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost. But testing push notifications using Firebase Cloud Messaging is an overhead. You need to ask you server team to send notifications everytime you need to test the push notifications implementation on your device. But not to worry, PushTry.com to the RESCUE… yayyy
Solution:
PushTry.com is an online tool through which you can send push notifications to either iOS device or an Android device while debugging or development. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app. This tool consists of iOS APNS Tester, Android GCM Tester and Google FCM tester but here we are only focusing on Google FCM Tester as there are many alternatives available for APNS testing as well as Android GCM testing. Let us see how Google FCM tester works:
Search for PushTry.com, you’ll find all the testers for sending push notifications. Scroll the loaded page once and you’ll find Google FCM Tester which is an ideal tool for both the iOS and Android. Select the JSON format and you’ll get the format of push notification payload:
How it works?
To move forward, first of all you need a server key or FCM token which you’ll get from your firebase console where your app is registered.
- Login to https://console.firebase.google.com, then select your project > your registered app.
- Click on overflow(three dots) button and select settings.
- Select CLOUD MESSAGING tab and copy the Server Key required for Google FCM testing.
When you get your Server Key or FCM token, you’ll need FCM registration token from devices on which you wan’t to send notifications. You can get FCM registration token from your code where you have authenticated your app with firebase during App launching. Your app will receive a new FCM registration token whenever firebase token is refreshed.
let refreshedToken = InstanceID.instanceID().token()
Now you have got both the Server Key as well as FCM registration token, you are almost ready to send your first FCM push notification to your testing devices. Just enter the Server key in FCM Token or Server Key field and FCM registration tokens(comma seperated) that you have got while registering your devices to firebase in multiple FCM Registration Token fields as well as in [add your token] field. Also enter all the other information like title and body of push and then Click on Send. If your JSON format is invalid, it will give an error else you’ll receive an acknowledgement of Firebase Push notification successfully sent.
Woww! You’ll heard a sound of push notification arrived on your device. And here we are done with the demo. Now go and start using PushTry.com – Firebase Cloud Messaging Testing Tool.