mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Introduce a local mechanism for managing the app's badge count
This commit is contained in:
@@ -158,6 +158,22 @@ final class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||
notificationCenter.removeDeliveredNotifications(withIdentifiers: notificationsIdentifiers)
|
||||
}
|
||||
|
||||
func updateAppBadgeCount() async {
|
||||
guard let userSession, appSettings.roomListNotificationCountEnabled else { return }
|
||||
|
||||
let badgeCount = Int(userSession.clientProxy.totalUnreadNotifications)
|
||||
|
||||
appSettings.lastKnownBadgeCount = badgeCount
|
||||
|
||||
MXLog.debug("Updating app badge count to \(badgeCount)")
|
||||
|
||||
do {
|
||||
try await notificationCenter.setBadgeCount(badgeCount)
|
||||
} catch {
|
||||
MXLog.error("Failed updating the app badge count with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
private func removeReceivedWhileOfflineNotification() {
|
||||
notificationCenter.removeDeliveredNotifications(withIdentifiers: [NotificationServiceExtensionActor.receivedWhileOfflineNotificationID])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user