Introduction
On a work project, we use Amazon SNS to send push notifications to a mobile app registered with Google's Firebase Cloud Messaging (FCM). Although Google was deprecating the Legacy FCM API at that time, SNS did not yet support the new HTTP V1 API. Last weekend, I received an email from AWS that SNS now supports the new API (yay!).
Procedures
This tutorial is written based on the steps I took to migrate to the V1 API. Please adjust accordingly.
-
Getting the Service JSON
- Log in to the Firebase console.
- Select the project that receives API calls from SNS.
- At the top left corner, click on the gear icon, and select Project Settings.
- At the top navigation under Project Settings, pick Service accounts.
- Click Generate new private key. A popup shows up reminding you to secure the key. Click *Generate key.
- The key should be downloaded.
-
Uploading the Service JSON
- Log in to the Amazon SNS console.
- Select Push notifications (under Mobile) from the left side menu. Pick the appropriate platform application.
- Edit the platform application. At the authentication method, pick Token (recommended). It will ask you to upload a service.json file. Pick the key downloaded previously from the Firebase console.
- Save changes.
-
Testing
- At the Platform application page, click on the link of an endpoint from the list below. At the top right-hand corner, click Publish message.
- At the Message body section, pick Custom payload and input the GCM message payload according to your platform (mine is Android).
- Check the app for notifications.
- To verify that it is using the new API, go back to the Firebase console Service accounts tab (refer to step 1.4). Click Manage service account permissions at the top-right-hand corner.
- At the Service accounts management page, locate the account associated with Firebase Admin SDK. Click the dots menu under Action on the right, and pick View metrics.
- Verify there were actions when the message was being sent.
Congratulations!
The migration is now complete. You may have to update the message payload to the new message format. Start exploring the multiplatform messaging capability now!
Top comments (0)