Push notification


Your android app should have a firebase cloud messaging integration to receive push notifications. Refer this doc to continue firebase cloud messaging integration

Updating fcm device token#

You need to update the fcm device token to the server, so that server can send push notificationns by using the updated fcm device token. if you want to update the fcm device token, you can utilise the below method.

FCM_TOKENStringfcm device token
CALLBACKChatActionListenercallback to observe the action status
PushNotificationManager.updateFcmToken(FCM_TOKEN, isSuccess, message) -> {

You need to call the above the method one time right after calling ChatConnectionManager.initialize() and then you have to always call in onNewToken of your firebase messaging service which extends FirebaseMessagingService.

Handling the received chat fcm message#

When you have received a firebase push notification in your firebase messaging service, you can easily identify the push notification received for the chat sdk and delegate the processing work to the sdk like below:

public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
Map<String, String> notificationData = remoteMessage.getData();
if (!notificationData.isEmpty() && notificationData.containsKey("push_from") && notificationData.get("push_from").equals("MirrorFly")) {
PushNotificationManager.handleReceivedMessage(notificationData, new NotificationEventListener() {
public void onMessageReceived(@NonNull ChatMessage chatMessage) {
// get unseen message list
List<ChatMessage> unseenMessagesForNotification = FlyMessenger.getLastNUnreadMessages(7);
for (ChatMessage message : unseenMessagesForNotification) {
String chatUserJid = message.getChatUserJid();
if (!ChatManager.isMuted(chatUserJid)) {
//for profile pic and other info's of group/user
ProfileDetails profileDetails = ContactManager.getProfileDetails(chatUserJid);
if (ChatTypeEnum.groupchat.equals(message.getMessageChatType())) {
//group chat sender user name
String groupUserName = ContactManager.getDisplayName(message.getSenderUserJid());
//for profile pic and other info's of group user
ProfileDetails groupUserProfile = ContactManager.getProfileDetails(message.getSenderUserJid());
//build up your notification
public void onGroupNotification(@NotNull String groupJid, @NotNull String titleContent, @NonNull ChatMessage chatMessage) {
/* Create the notification for group creation with parameter values */
public void onCancelNotification() {
// here you have to cancel notification

Get unread count without muted chat messages#

If you need a unread count excluding the muted chat messages, you can utilise the below method.


Get last N unread messages#

The below method can be used to return the last N unread messages from the sdk, so that you can utilise the data to build up your own notification

COUNTintrecent messages count to be retrieved

Group recent N unread messages#

The below method can be used to return the recent N unread messages from the sdk which are group by users/group

Map<String, List<ChatMessage>> usersWithMessage = ChatManager.getNUnreadMessagesOfEachUsers(COUNT);
COUNTintno of unread messages has to be returned for each user

Key of the Map holds the jid of the user/group and the value holds the list of unread message for that user/group.


Sdk is having a built-in functions to prepare the JID, Group JID.