Push Notifications using FCM
Firebase cloud messaging is cross platform which supports Android, iOS and mobile wep applications.
Create new android studio project.
Log in to FCM console. Create or Add a project.
Give the project name & select the country
Select “Add Firebase to your android app”
Give your app package name and click on Register App.
Then you will receive google-services.json file.
Navigate to android app folder and paste google-services.json.
Add the following code to the root level build.gradle file.
In the app level build.gradle add the plugin for google-services
Declare Activity & intent fliters to AndroidManifest.xml
Create a class called FirebaseIdService and get the registration token.
Add following lines of code to handle notification using Broadcast Receiver.
On Launch of MainActivity.kt register Broadcast receiver to check if we have any push notifications and unregister to release the resources. Also design the notification style.
From FCM console, select the created app
Select Notifications option from navigation menu.
Then select New Message and enter the message title and content and finally click on Send Message buton.