mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Update the app badge after receiving a notification by reading and using the unreadCount from the request payload
This commit is contained in:
parent
e9a945cfe4
commit
3bc474fb70
@ -60,7 +60,8 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
Task {
|
||||
await run(with: credentials,
|
||||
roomId: roomId,
|
||||
eventId: eventId)
|
||||
eventId: eventId,
|
||||
unreadCount: request.unreadCount)
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +74,8 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
|
||||
private func run(with credentials: KeychainCredentials,
|
||||
roomId: String,
|
||||
eventId: String) async {
|
||||
eventId: String,
|
||||
unreadCount: Int?) async {
|
||||
MXLog.info("\(tag) run with roomId: \(roomId), eventId: \(eventId)")
|
||||
|
||||
do {
|
||||
@ -102,6 +104,12 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
modifiedContent = latestContent
|
||||
}
|
||||
// We still notify, but without the media attachment if it fails to load
|
||||
|
||||
// Finally update the app badge
|
||||
if let unreadCount {
|
||||
modifiedContent?.badge = NSNumber(value: unreadCount)
|
||||
}
|
||||
|
||||
return notify()
|
||||
} catch {
|
||||
MXLog.error("NSE run error: \(error)")
|
||||
|
Loading…
x
Reference in New Issue
Block a user