google-services.json
file and place it in the required location in your project.build.gradle
file.build.gradle
file.V2
to start using the token-based version of the Push Notification extension.V1
and want to migrate your app to use V2
, then Select V1 & V2
option. This ensures that the users viewing the older version of your app also receive Push Notifications.V2
, thus turning off V1
(Topic-based) Push Notifications completely.CometChat.registerTokenForPushNotification()
function call. (You can see the process of getting the FCM Token in the next step)onNewToken()
method. This token is stored as a String variable. You can choose to store it in SharedPreferences as well.pushNotification
key followed by some user-defined string for the notification body inside metadata
while sending the message.
The following code shows an example of a Custom body using a message of category=custom. This is however not just limited to a custom category of messages.
CometChatHelper.processMessage()
to convert the message JSON to the corresponding object of TextMessage
, MediaMessage
, CustomMessage
, Action
or Call
.
This code needs to be added to the onMessageReceived()
method of the FirebaseMessagingService
class.
CometChatConstants.MESSAGE_TYPE_IMAGE
CometChatConstants.MESSAGE_TYPE_VIDEO
CometChatConstants.MESSAGE_TYPE_AUDIO
CometChatConstants.MESSAGE_TYPE_FILE
onMessageReceived(RemoteMessage message)
. You need to call CometChat.processMessage()
method to process push notification payload.