FCM messages

Using FCM, you can send two types of messages to the clients: Notification Messages and Data Messages. The maximum payload size for both kinds of messages is 4 KB when using Firebase SDK. However, when you send messages from the Firebase console, it enforces a 1024 character limit.

The notification messages are handled by FCM SDK automatically, since they are just display messages. You can use notification messages when you want FCM to display a notification on your client app's behalf. Notification messages contain a predefined set of keys and can also contain an optional data payload.

The notification message object looks like this:

{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{
"title":"This is an FCM notification message!",
"body":"FCM message"
}
}
}

The data messages are handled by a client app and contain the user-defined keys. They look as follows:

{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data":{
"Name" : "MT",
"Education" : "Ph.D."
}
}
}

We will see what a token is in the upcoming sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset