What is Firebase Cloud Message
FCM is a free, cross-platform messaging solution that lets you send push notifications to your audience, without having to worry about the server code. By using FCM alongside Firebase's Notifications Composer (as seen in the following screenshot), you can create notifications that target very specific sections of your user base, often without having to write any special code.
Using Firebase Cloud Messaging you can send three types of messages:
- Notification Message
- Data Message
- Both Notification and Data
Notification Message: Notification messages are handled by Firebase SDK itself. Typically the notification message contains title, message, icon etc., These message can be sent from Firebase console UI. By sending this kind of messages, you won't get much control over the notification. The notification will be shown automatically when the app is in background.
In order to send notification message, you need to use notification key in json data. An example of notification message is given below:
Data Message: Data messages has to be handled by the android app. You can add this kind of messages if you want to send some additional data along with the notification. But sending these messages through Firebase console is not possible. You need to have a server side logic to send the notification using Firebase API. You need to use data key when sending this message.
An example of data message json is given below
Now let's Integrating FCM