Android Push Notification Flow using FCM
- Authors
- Name
- Pallavi
- Published on
I am Pallavi, Co-Founder @ Outcome School, experienced in creating robust and scalable backend systems. I love working on performance optimization and security. I am passionate about knowledge sharing, mentoring developers, and contributing to technical blogs.
Join Outcome School and get high paying tech job: Outcome School
In this blog, we will learn about the Android Push Notification Flow using FCM.
When we add the Push Notification feature in Android, there are many steps involved at both the Android and Backend levels. We will try to learn about all the steps involved in the Android Push Notification Flow using FCM.
Let's begin.
We have created a complete flow diagram to help you understand easily. Just follow the steps in the diagram with the explanation below in this blog.
Step 1
Set up the app on Firebase Console by entering details like the Android package name.
Step 2
The FCM Server will generate:
- google-services.json: This json file contains all the necessary credentials and settings for Android app. It is placed in client code i.e., Android project. To get this json file, Go to the Firebase Console -> Select Your Project -> Add an Android App to Your Project (if not already added) -> Download
google-services.json
. - service-account.json: This is used for sending push notifications from backend server. This should be kept private and secure. To get this json file, Go to the Firebase Console -> Select Your Project -> Navigate to Project Settings -> Go to the Service Accounts Tab -> Generate a New Private Key -> Download
service-account.json
.
Step 3
When the app is launched, it connects to the FCM server.
Step 4
The FCM Server generates a unique token(FCM token) and sends it to the app.
Step 5
The client developer will write the code to send the FCM token to the backend server, which the backend server will store.
Step 6
When the backend server has to send the notification to that user, for example - when someone comments on your post, the backend server sends the access token(this is fetched from FCM server using the private key present in the service-account.json file), the FCM token and the content of notification to FCM Server.
Step 7
The FCM Server then sends the notification to the user.
That's it for now.
Thanks
Pallavi
Co-Founder @ Outcome School
You can connect with me on:
Follow Outcome School on: