Directory Image
This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Privacy Policy.

Discuss the different types of messages that can be sent using the cloud messaging APIs.

Author: Mobility Inclusive
by Mobility Inclusive
Posted: Sep 13, 2022

With Cloud Messaging API, we can send three types of messages, i.e. H Notification message, Data message, and payload message.

1. Warning message

Firebase SDK handled the notification messages itself. Typically, the notification includes the title, icon, message, etc. These messages can also be sent from the Firebase Console UI. By sending this type of message, we do not have much control over the information. The message appears automatically

small icon

It is essential to set a small icon in the notification. This small icon is set with setSmallIcon ().

Application name

The application name is provided by the system.

Timestamp

The timestamp is also provided by the system, but we can override it with the setWhen () function or hide it with the setShowWhen () function.

Title

It is also optional and is set with the setContentTitle () function. Text

The text is optional and is set with setContentText ().

big icon

This is optional and we use it for contact photos. We don't use it for our app icon and set it with the setLargeIcon () function.

2. Data message:

Data messages are handled by the Android app. If we want to send some additional details with the information, we can add such messages. However, these messages cannot be sent through the Firebase console. To send notifications using the Firebase API, we need the server logic. We must use the data key when sending this message.

We can use data messages to send custom data elements to a client application. However, FCM places a limit of 4 KB for these data messages, so if our payload is greater than 4 KB, we need to get additional data using the WorkManager or JobScheduler API.

3. Messages with notification and useful data

Notification and data payloads can also be included in a message. Sending these types of messages will depend on the state of the application, i.e. H Background and Foreground, handled in two scenarios. We may use both notification and data keys for these messages.

If the app state is in the background, apps will receive the notification payload when the user taps the notification, and if it is in the foreground, the app will receive a message object with both payloads available.

when the app is running in the background. A notification is a message that Android displays outside of our app's user interface to provide users with reminders, communications with others, or other timely information about our app. Users can tap the notification to open our app or take action directly from the notification.

About the Author

Fauzia sumbul is a seo specialist having 5+years of experience with leading brands like Infosys,bata and mobilityinclusive.Follow her on twitter.

Rate this Article
Leave a Comment
Author Thumbnail
I Agree:
Comment 
Pictures
Author: Mobility Inclusive

Mobility Inclusive

Member since: Sep 06, 2022
Published articles: 2

Related Articles