-
Notifications
You must be signed in to change notification settings - Fork 21
Managing badge number for seen messages
By design, MobileMessaging.setSeen(...)
does not decrement the badge number - it only marks the specific messages as seen and persists the actual seen status. In order to maintain the badge number, you need to explicitly set it as follows:
MobileMessaging.badgeNumber = <new value>
There is more convenient way to maintain badge number though.
When using Default Message Storage you can leverage a special handler MMDefaultMessageStorage.messagesCountersUpdateHandler
that will be called each time the message set as seen (MobileMessaging.setSeen(...)
does this as mentioned before).
The handler will pass total number of messages along with non-seen counter. Inside the handler you can set badge number:
MobileMessaging.defaultMessageStorage?.messagesCountersUpdateHandler = { total, nonSeen in
MobileMessaging.badgeNumber = nonSeen
}
You may also want to mark all the storage messages as seen, the most efficient way would be as follows:
MobileMessaging.defaultMessageStorage?.findNonSeenMessageIds { (messageIds) in
MobileMessaging.setSeen(messageIds: messageIds)
}
If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
- Geofencing service
- Privacy settings
- In-app chat
- WebRTC Calls and UI