TF-2464 Sort list new emails push notification by receivedAt

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit 44a1f4a44c9bc5612cef610334ce01dbaff9e051)
This commit is contained in:
dab246
2024-01-17 11:33:29 +07:00
committed by Dat PHAM HOANG
parent f7a2fd903d
commit eb8c27d38e
6 changed files with 54 additions and 22 deletions
+5 -4
View File
@@ -88,7 +88,7 @@ import flutter_local_notifications
if let notificationBadgeCount = notification.request.content.badge?.intValue, notificationBadgeCount > 0 {
let newBadgeCount = UIApplication.shared.applicationIconBadgeNumber + notificationBadgeCount
TwakeLogger.shared.log(message: "AppDelegate::userNotificationCenter::willPresent:newBadgeCount: \(newBadgeCount)")
updateAppBadger(currentBadgeCount: newBadgeCount)
updateAppBadger(newBadgeCount: newBadgeCount)
}
if let emailId = notification.request.content.userInfo[JmapConstants.EMAIL_ID] as? String,
!emailId.isEmpty,
@@ -101,7 +101,9 @@ import flutter_local_notifications
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
TwakeLogger.shared.log(message: "AppDelegate::userNotificationCenter::didReceive::response: \(response)")
updateAppBadger(currentBadgeCount: UIApplication.shared.applicationIconBadgeNumber)
let currentBadgeCount = UIApplication.shared.applicationIconBadgeNumber
let newBadgeCount = currentBadgeCount > 0 ? currentBadgeCount - 1 : 0
updateAppBadger(newBadgeCount: newBadgeCount)
if let emailId = response.notification.request.content.userInfo[JmapConstants.EMAIL_ID] as? String {
self.notificationInteractionChannel?.invokeMethod("openEmail", arguments: emailId)
@@ -112,8 +114,7 @@ import flutter_local_notifications
}
extension AppDelegate {
private func updateAppBadger(currentBadgeCount: Int) {
let newBadgeCount = currentBadgeCount > 0 ? currentBadgeCount - 1 : 0
private func updateAppBadger(newBadgeCount: Int) {
TwakeLogger.shared.log(message: "AppDelegate::updateAppBadger::newBadgeCount: \(newBadgeCount)")
if #available(iOS 16.0, *) {
UNUserNotificationCenter.current().setBadgeCount(newBadgeCount)