Fix: Support multiple language for notification default message
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit 1172d4365f1365f4688475bcde3d76ea4e1883b5)
This commit is contained in:
@@ -28,6 +28,8 @@
|
|||||||
F53D1E862B2E401B00051FD0 /* JmapRequestGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F53D1E852B2E401B00051FD0 /* JmapRequestGenerator.swift */; };
|
F53D1E862B2E401B00051FD0 /* JmapRequestGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F53D1E852B2E401B00051FD0 /* JmapRequestGenerator.swift */; };
|
||||||
F53D1E882B2E4B3B00051FD0 /* AuthenticationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F53D1E872B2E4B3B00051FD0 /* AuthenticationType.swift */; };
|
F53D1E882B2E4B3B00051FD0 /* AuthenticationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = F53D1E872B2E4B3B00051FD0 /* AuthenticationType.swift */; };
|
||||||
F53D1E8A2B2E4BB700051FD0 /* TokenOidc.swift in Sources */ = {isa = PBXBuildFile; fileRef = F53D1E892B2E4BB700051FD0 /* TokenOidc.swift */; };
|
F53D1E8A2B2E4BB700051FD0 /* TokenOidc.swift in Sources */ = {isa = PBXBuildFile; fileRef = F53D1E892B2E4BB700051FD0 /* TokenOidc.swift */; };
|
||||||
|
F5550D292B4E90A7003DD2AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F5550D2C2B4E90A7003DD2AE /* Localizable.strings */; };
|
||||||
|
F5550D2A2B4E90A7003DD2AE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F5550D2C2B4E90A7003DD2AE /* Localizable.strings */; };
|
||||||
F5630C762B2CDFDA003CC0FD /* KeychainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5630C752B2CDFDA003CC0FD /* KeychainController.swift */; };
|
F5630C762B2CDFDA003CC0FD /* KeychainController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5630C752B2CDFDA003CC0FD /* KeychainController.swift */; };
|
||||||
F5630C782B2CE091003CC0FD /* KeyChainControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5630C772B2CE091003CC0FD /* KeyChainControllerDelegate.swift */; };
|
F5630C782B2CE091003CC0FD /* KeyChainControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5630C772B2CE091003CC0FD /* KeyChainControllerDelegate.swift */; };
|
||||||
F5630C7B2B2CE148003CC0FD /* KeychainSharingSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5630C7A2B2CE148003CC0FD /* KeychainSharingSession.swift */; };
|
F5630C7B2B2CE148003CC0FD /* KeychainSharingSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = F5630C7A2B2CE148003CC0FD /* KeychainSharingSession.swift */; };
|
||||||
@@ -134,6 +136,10 @@
|
|||||||
F53D1E852B2E401B00051FD0 /* JmapRequestGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JmapRequestGenerator.swift; sourceTree = "<group>"; };
|
F53D1E852B2E401B00051FD0 /* JmapRequestGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JmapRequestGenerator.swift; sourceTree = "<group>"; };
|
||||||
F53D1E872B2E4B3B00051FD0 /* AuthenticationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationType.swift; sourceTree = "<group>"; };
|
F53D1E872B2E4B3B00051FD0 /* AuthenticationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationType.swift; sourceTree = "<group>"; };
|
||||||
F53D1E892B2E4BB700051FD0 /* TokenOidc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenOidc.swift; sourceTree = "<group>"; };
|
F53D1E892B2E4BB700051FD0 /* TokenOidc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenOidc.swift; sourceTree = "<group>"; };
|
||||||
|
F5550D2B2B4E90A7003DD2AE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
F5550D2D2B4E90C6003DD2AE /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
F5550D2E2B4E90D5003DD2AE /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
|
F5550D2F2B4E90E2003DD2AE /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
F5630C752B2CDFDA003CC0FD /* KeychainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainController.swift; sourceTree = "<group>"; };
|
F5630C752B2CDFDA003CC0FD /* KeychainController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainController.swift; sourceTree = "<group>"; };
|
||||||
F5630C772B2CE091003CC0FD /* KeyChainControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyChainControllerDelegate.swift; sourceTree = "<group>"; };
|
F5630C772B2CE091003CC0FD /* KeyChainControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyChainControllerDelegate.swift; sourceTree = "<group>"; };
|
||||||
F5630C7A2B2CE148003CC0FD /* KeychainSharingSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainSharingSession.swift; sourceTree = "<group>"; };
|
F5630C7A2B2CE148003CC0FD /* KeychainSharingSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainSharingSession.swift; sourceTree = "<group>"; };
|
||||||
@@ -243,6 +249,7 @@
|
|||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
|
F5550D2C2B4E90A7003DD2AE /* Localizable.strings */,
|
||||||
);
|
);
|
||||||
path = Runner;
|
path = Runner;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -530,6 +537,9 @@
|
|||||||
knownRegions = (
|
knownRegions = (
|
||||||
en,
|
en,
|
||||||
Base,
|
Base,
|
||||||
|
vi,
|
||||||
|
fr,
|
||||||
|
ru,
|
||||||
);
|
);
|
||||||
mainGroup = 97C146E51CF9000F007C117D;
|
mainGroup = 97C146E51CF9000F007C117D;
|
||||||
packageReferences = (
|
packageReferences = (
|
||||||
@@ -552,6 +562,7 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
F5550D292B4E90A7003DD2AE /* Localizable.strings in Resources */,
|
||||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||||
@@ -571,6 +582,7 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
F5550D2A2B4E90A7003DD2AE /* Localizable.strings in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -748,6 +760,17 @@
|
|||||||
name = MainInterface.storyboard;
|
name = MainInterface.storyboard;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
F5550D2C2B4E90A7003DD2AE /* Localizable.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
F5550D2B2B4E90A7003DD2AE /* en */,
|
||||||
|
F5550D2D2B4E90C6003DD2AE /* vi */,
|
||||||
|
F5550D2E2B4E90D5003DD2AE /* fr */,
|
||||||
|
F5550D2F2B4E90E2003DD2AE /* ru */,
|
||||||
|
);
|
||||||
|
name = Localizable.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXVariantGroup section */
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
@@ -755,6 +778,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@@ -834,6 +858,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@@ -889,6 +914,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
"newMessageInTwakeMail" = "You have new emails";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"newMessageInTwakeMail" = "Vous avez de nouveaux e-mails";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"newMessageInTwakeMail" = "У вас есть новые электронные письма";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"newMessageInTwakeMail" = "Bạn có email mới";
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import UserNotifications
|
import UserNotifications
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
class NotificationService: UNNotificationServiceExtension {
|
class NotificationService: UNNotificationServiceExtension {
|
||||||
|
|
||||||
private let timeIntervalNotificationTriggerInSecond: Int = 2
|
private let timeIntervalNotificationTriggerInSecond: Int = 2
|
||||||
private let newEmailDefaultMessage: String = "You have new emails"
|
private let newEmailDefaultMessageKey: String = "newMessageInTwakeMail"
|
||||||
|
|
||||||
private var handler: ((UNNotificationContent) -> Void)?
|
private var handler: ((UNNotificationContent) -> Void)?
|
||||||
private var modifiedContent: UNMutableNotificationContent?
|
private var modifiedContent: UNMutableNotificationContent?
|
||||||
@@ -14,12 +15,13 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||||
handler = contentHandler
|
handler = contentHandler
|
||||||
modifiedContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
modifiedContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
|
||||||
|
|
||||||
self.modifiedContent?.title = InfoPlistReader(bundle: .app).bundleDisplayName
|
self.modifiedContent?.title = InfoPlistReader(bundle: .app).bundleDisplayName
|
||||||
|
self.modifiedContent?.body = NSLocalizedString(newEmailDefaultMessageKey, comment: "Localizable")
|
||||||
|
self.modifiedContent?.badge = NSNumber(value: 1)
|
||||||
|
|
||||||
guard let payloadData = request.content.userInfo as? [String: Any],
|
guard let payloadData = request.content.userInfo as? [String: Any],
|
||||||
!keychainController.retrieveSharingSessions().isEmpty else {
|
!keychainController.retrieveSharingSessions().isEmpty else {
|
||||||
self.modifiedContent?.body = newEmailDefaultMessage
|
|
||||||
self.modifiedContent?.badge = NSNumber(value: 1)
|
|
||||||
return self.notify()
|
return self.notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +40,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
let mapStateChanges: [String: [TypeName: String]] = PayloadParser.shared.parsingPayloadNotification(payloadData: payloadData)
|
let mapStateChanges: [String: [TypeName: String]] = PayloadParser.shared.parsingPayloadNotification(payloadData: payloadData)
|
||||||
|
|
||||||
if (mapStateChanges.isEmpty) {
|
if (mapStateChanges.isEmpty) {
|
||||||
self.modifiedContent?.body = newEmailDefaultMessage
|
|
||||||
self.modifiedContent?.badge = NSNumber(value: 1)
|
|
||||||
return self.notify()
|
return self.notify()
|
||||||
} else {
|
} else {
|
||||||
guard let currentAccountId = mapStateChanges.keys.first,
|
guard let currentAccountId = mapStateChanges.keys.first,
|
||||||
@@ -49,8 +49,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
let oldEmailState = keychainSharingSession.emailState,
|
let oldEmailState = keychainSharingSession.emailState,
|
||||||
newEmailState != oldEmailState,
|
newEmailState != oldEmailState,
|
||||||
keychainSharingSession.tokenOIDC != nil || keychainSharingSession.basicAuth != nil else {
|
keychainSharingSession.tokenOIDC != nil || keychainSharingSession.basicAuth != nil else {
|
||||||
self.modifiedContent?.body = newEmailDefaultMessage
|
|
||||||
self.modifiedContent?.badge = NSNumber(value: 1)
|
|
||||||
return self.notify()
|
return self.notify()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,8 +63,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
oidcScopes: keychainSharingSession.oidcScopes,
|
oidcScopes: keychainSharingSession.oidcScopes,
|
||||||
onComplete: { (emails, errors) in
|
onComplete: { (emails, errors) in
|
||||||
if emails.isEmpty {
|
if emails.isEmpty {
|
||||||
self.modifiedContent?.body = self.newEmailDefaultMessage
|
|
||||||
self.modifiedContent?.badge = NSNumber(value: 1)
|
|
||||||
return self.notify()
|
return self.notify()
|
||||||
} else {
|
} else {
|
||||||
self.keychainController.updateEmailStateToKeychain(accountId: keychainSharingSession.accountId, newState: newEmailState)
|
self.keychainController.updateEmailStateToKeychain(accountId: keychainSharingSession.accountId, newState: newEmailState)
|
||||||
@@ -136,7 +132,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func discard() {
|
private func discard() {
|
||||||
handler?(UNMutableNotificationContent())
|
handler?(UNNotificationContent())
|
||||||
cleanUp()
|
cleanUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user