From 4f1093beca5ac5b00b2341b0791428ffe690c9db Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 23 Nov 2021 11:58:19 +1100 Subject: [PATCH] improve translation and notificaiton displaying --- Session/Meta/Translations/en.lproj/Localizable.strings | 3 ++- Session/Notifications/UserNotificationsAdaptee.swift | 2 +- SignalUtilitiesKit/Utilities/CommonStrings.swift | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index 3e0abe961..beddf5196 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -572,7 +572,8 @@ "DISMISS_BUTTON_TEXT" = "Dismiss"; /* Button text which opens the settings app */ "OPEN_SETTINGS_BUTTON" = "Settings"; -"APN_Message" = "You've got a new message"; +"APN_Message" = "You've got a new message."; +"APN_Collapsed_Messages" = "You've got %@ new messages."; "system_mode_theme" = "System"; "dark_mode_theme" = "Dark"; "light_mode_theme" = "Light"; diff --git a/Session/Notifications/UserNotificationsAdaptee.swift b/Session/Notifications/UserNotificationsAdaptee.swift index 551224aaf..e5997f9a9 100644 --- a/Session/Notifications/UserNotificationsAdaptee.swift +++ b/Session/Notifications/UserNotificationsAdaptee.swift @@ -127,11 +127,11 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee { let numberOfNotifications: Int if let lastRequest = notifications[notificationIdentifier], let counter = lastRequest.content.userInfo[AppNotificationUserInfoKey.threadNotificationCounter] as? Int { numberOfNotifications = counter + 1 + content.body = String(format: NotificationStrings.incomingCollapsedMessagesBody, "\(numberOfNotifications)") } else { numberOfNotifications = 1 } content.userInfo[AppNotificationUserInfoKey.threadNotificationCounter] = numberOfNotifications - content.body = "\(numberOfNotifications) new messages." } else { trigger = nil } diff --git a/SignalUtilitiesKit/Utilities/CommonStrings.swift b/SignalUtilitiesKit/Utilities/CommonStrings.swift index a5e4649d3..2d7199593 100644 --- a/SignalUtilitiesKit/Utilities/CommonStrings.swift +++ b/SignalUtilitiesKit/Utilities/CommonStrings.swift @@ -50,6 +50,9 @@ public class NotificationStrings: NSObject { @objc static public let incomingMessageBody = NSLocalizedString("APN_Message", comment: "notification body") + + @objc + static public let incomingCollapsedMessagesBody = NSLocalizedString("APN_Collapsed_Messages", comment: "collapsed notification body for background polling") @objc static public let incomingGroupMessageTitleFormat = NSLocalizedString("NEW_GROUP_MESSAGE_NOTIFICATION_TITLE", comment: "notification title. Embeds {{author name}} and {{group name}}")