Эх сурвалжийг харах

detect twofactor_nextcloud_notification

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 жил өмнө
parent
commit
8957038d3c

+ 9 - 4
iOSClient/AppDelegate.swift

@@ -443,28 +443,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCApplicationHandle().nextcloudPushNotificationAction(data: data) { detected in
             if !detected {
 
-                var openNotification: Bool = false
+                var findAccount: Bool = false
 
                 if let accountPush = data["account"] as? String,
                    let app = data["app"] as? String,
                    app == NCGlobal.shared.twofactorNotificatioName {
                     if accountPush == self.account {
-                        openNotification = true
+                        findAccount = true
                     } else {
                         let accounts = NCManageDatabase.shared.getAllAccount()
                         for account in accounts {
                             if account.account == accountPush {
                                 self.changeAccount(account.account)
-                                openNotification = true
+                                findAccount = true
                             }
                         }
                     }
-                    if openNotification, let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
+                    if findAccount, let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
                         DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                             let navigationController = UINavigationController(rootViewController: viewController)
                             navigationController.modalPresentationStyle = .fullScreen
                             self.window?.rootViewController?.present(navigationController, animated: true)
                         }
+                    } else if !findAccount {
+                        let message = NSLocalizedString("_the_account_", comment: "") + " " + accountPush + " " + NSLocalizedString("_does_not_exist_", comment: "")
+                        let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
+                        alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+                        self.window?.rootViewController?.present(alertController, animated: true, completion: { })
                     }
                 }
             }

+ 2 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -113,6 +113,8 @@
 "_purchase_"                = "Purchase";
 "_account_not_available_"   = "The account %@ of %@ does not exist, please add it to be able to read the file %@";
 "_account_not_exists_"      = "The account %@ of %@ does not exist";
+"_the_account_"             = "The account";
+"_does_not_exist_"          = "does not exist";
 "_error_parameter_schema_"  = "Wrong parameters, impossible to continue";
 "_comments_"                = "Comments";
 "_sharing_"                 = "Sharing";