Push Notifications
Push Notifications allows your users to receive important messages when the app is running in the background or a device is idle. Push Notifications for Android are sent using FCM.
Register FCM Token
Register FCM token on Channelize.io server using the following code.
* @param FCM_TOKEN // New FCM token which you need to register on your server.
Channelize channelize = Channelize.getInstance();
channelize.registerFcmToken(FCM_TOKEN);
Update FCM Token
When an FCM token is refreshed then you've to update it on Channelize.io server using the following code.
* @param FCM_TOKEN // Updated FCM token which you need to register on your server.
Channelize channelize = Channelize.getInstance();
channelize.updateFcmToken(FCM_TOKEN);
Response data
// Below key-value data is coming in **RemoteMessage** of **FirebaseMessagingService** :
* @param MESSAGE_ID The unique Id of the message for which push notification has arrived.
* @param CHAT_ID The unique Id of the conversation in which message is received.
* @param messageType **Unique type and always channelize**.
* @param isMessenger **Unique type and always 1**.
* @param BODY_OF_MESSAGE The content of the message.
* @param CHAT_PROFILE_ICON Profile image URL of the conversation.
* @param MESSAGE_SENDER_NAME Name of the message sender.
* @param type Type of the pushnotification- **message**.
* @param recipient JSONObject of the recipient to ensure that logged-in user must be equal to recipientId.
* @param USER_ID_OF_RECEIVER The unique Id of the user for which push notification has been arrived.
* @param STATUS_OF_MESSAGE Status of the message. Must be 1,2 or 3.
* @param MESSAGE_TIME_STAMP The timestamp when the message was received.
* @param IS_GROUP True, if the push notification is for a group message otherwise false.
{messageId=MESSAGE_ID, chatId=CHAT_ID, messageType=channelize, isMessenger=1, tag=CHAT_ID,
body=BODY_OF_MESSAGE, icon=CHAT_PROFILE_ICON, type=message, sound=default, title=MESSAGE_SENDER_NAME,
recipient={"id":"UNIQUE_RECIPIENT_ID","recipientId":"USER_ID_OF_RECEIVER","status":STATUS_OF_MESSAGE,
"createdAt":"MESSAGE_TIME_STAMP"}, isGroup=IS_GROUP}