How to send Firebase Push Notifications with AWS SNS
Firebase cloud messaging (FCM) is a service which enables you to send message or notification on Android device. This session describes how to obtain the FCM prerequisites and send push notification messages to a mobile endpoint. Push notification is sort of message or notification, you can send to users even when they are not actively using your app. Read more about FCM
How push notification works:-
– For push notification, firstly we have to create an app for supported device and messaging API. After registering your app on platform notification service (wills discussion in the next step), you will end up with some sort of token or identifier that is unique to each device.
AWS SNS uses these token or identifier to send notification by creating mobile endpoint. Read about AWS SNS.
Points to cover:-
- How to create project in FCM
- How to obtain server API key.
- Send notification to mobile device
1. How to create a project in FCM.
2. To create FCM project, go to https://console.firebase.google.com/ and click on add project.
4. How to obtain the server API key.
5. Now creating server key, go to setting->Cloud Messaging.
6. Make note of server key from project credential. If you don’t have server key then click on Add server Key.
Send notification on mobile deviceFor sending notification on mobile device, you first need to register an app with AWS. Registration of application is nothing but creating platform application on AWS SNS.
7. For creating application platform, go to AWS SNS console and choose Create platform application.
8. Enter the application name in the box and choose the GCM application platform.
11. When an app and mobile device is registered on push notification service, the notification service gives you a device token. This device token is used to create platform endpoint, once you create endpoint you can publish the message to the mobile device.
12.To create endpoint, click on create platform endpoint.
Once you created an endpoint, SNS gives us endpoint ARN. Now, this is ready to send a message to this endpoint. Make sure the device token will change when your app is reinstalled.
In this session, we have seen how to send SNS a push notification by creating a project in FCM. You can use another notification service like ADM (Amazon Device Messaging), Baidu, etc and send a notification to mobile device.
Contributed by :