TF-2871 Fix notification loss error when sending multiple notifications simultaneously.

This commit is contained in:
dab246
2024-05-21 02:11:13 +07:00
committed by Dat H. Pham
parent d3bc5912fb
commit ef159c78c5
+3 -3
View File
@@ -94,7 +94,7 @@ class NotificationService: UNNotificationServiceExtension {
badgeCount: emails.count, badgeCount: emails.count,
userInfo: [JmapConstants.EMAIL_ID : email.id]) userInfo: [JmapConstants.EMAIL_ID : email.id])
return self.notify() return self.notify()
} } else {
self.showNewNotification(title: email.getSenderName(), self.showNewNotification(title: email.getSenderName(),
subtitle: email.subject, subtitle: email.subject,
body: email.preview, body: email.preview,
@@ -102,6 +102,7 @@ class NotificationService: UNNotificationServiceExtension {
notificationId: email.id, notificationId: email.id,
userInfo: [JmapConstants.EMAIL_ID : email.id]) userInfo: [JmapConstants.EMAIL_ID : email.id])
} }
}
} else { } else {
self.showModifiedNotification(title: emails.first!.getSenderName(), self.showModifiedNotification(title: emails.first!.getSenderName(),
subtitle: emails.first!.subject, subtitle: emails.first!.subject,
@@ -157,8 +158,7 @@ class NotificationService: UNNotificationServiceExtension {
content.userInfo = userInfo content.userInfo = userInfo
// Create a notification trigger // Create a notification trigger
let triggerDateTime = Calendar.current.dateComponents([.hour, .minute, .second], from: Date()) let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 2, repeats: false)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDateTime, repeats: false)
// Create a notification request // Create a notification request
let request = UNNotificationRequest(identifier: notificationId, content: content, trigger: trigger) let request = UNNotificationRequest(identifier: notificationId, content: content, trigger: trigger)