FCM clients require devices running Android 2.3 or higher that also have the Google Play Store app installed, or an emulator running Android 2.3 with Google APIs. Note that you are not limited to deploying your Android apps through Google Play Store.
Set up Firebase and the FCM SDK
- First step want to insert google-services.json file in your App. For this tutorial please refer my previous post Firebase Cloud Messaging Android.
After that insert Firebase and google sdk in your gradle.
2.apply plugin: ‘com.google.gms.google-services’
Please refer this image.
- Now go to your root level build.gradle file and add your google services class path.
Change your Manifest
- Manifest you want to add
FirebaseMessagingService. This is helps to handling your notifications in background. To receive notifications in foregrounded apps, to receive data payload, to send upstream messages, and so on, you must extend this service.
- Then you want add
FirebaseInstanceIdServiceto handle the creation, rotation, and updating of registration tokens. This is required for sending to specific devices or for creating device groups.
FireBase messaging Implementation in APP
- Create Background FireBase message service class.
- Create New FireBaseinstanceid class.
- Finish your process in Application side. just run your app now.
- you will get New token check your log cat.
For full source code please click this link
I hope this tutorial helps you in creating your first FCM Notification App. For more info click here. If you have any questions please post in comments section.