소스 검색

fix Push Notification - TwoFactor Notification

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 년 전
부모
커밋
f35496800d
4개의 변경된 파일30개의 추가작업 그리고 32개의 파일을 삭제
  1. 2 2
      ExternalResources/NCApplicationHandle.swift
  2. 26 28
      iOSClient/AppDelegate.swift
  3. 1 1
      iOSClient/NCGlobal.swift
  4. 1 1
      iOSClient/Notification/NCNotification.swift

+ 2 - 2
ExternalResources/NCApplicationHandle.swift

@@ -32,8 +32,8 @@ class NCApplicationHandle: NSObject {
 
     // class: AppDelegate
     // func nextcloudPushNotificationAction(data: [String: AnyObject])
-    func nextcloudPushNotificationAction(data: [String: AnyObject], completion: @escaping (_ detected: Bool) -> Void) {
-        completion(false)
+    func nextcloudPushNotificationAction(data: [String: AnyObject], completion: @escaping () -> Void) {
+        completion()
     }
 
     // class: AppDelegate

+ 26 - 28
iOSClient/AppDelegate.swift

@@ -439,37 +439,35 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
 
     func nextcloudPushNotificationAction(data: [String: AnyObject]) {
-        NCApplicationHandle().nextcloudPushNotificationAction(data: data) { detected in
-            if !detected {
-
-                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 {
-                        findAccount = true
-                    } else {
-                        let accounts = NCManageDatabase.shared.getAllAccount()
-                        for account in accounts {
-                            if account.account == accountPush {
-                                self.changeAccount(account.account)
-                                findAccount = true
-                            }
+        NCApplicationHandle().nextcloudPushNotificationAction(data: data) {
+
+            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 {
+                    findAccount = true
+                } else {
+                    let accounts = NCManageDatabase.shared.getAllAccount()
+                    for account in accounts {
+                        if account.account == accountPush {
+                            self.changeAccount(account.account)
+                            findAccount = true
                         }
                     }
-                    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: { })
+                }
+                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: { })
                 }
             }
         }

+ 1 - 1
iOSClient/NCGlobal.swift

@@ -92,7 +92,7 @@ class NCGlobal: NSObject {
     let appScheme                                   = "nextcloud"
     let talkName                                    = "talk-message"
     let spreedName                                  = "spreed"
-    let twofactorNotificatioName                    = "twofactor_nextcloud_notification"
+    let twoFactorNotificatioName                    = "twofactor_nextcloud_notification"
 
     // Nextcloud version
     //

+ 1 - 1
iOSClient/Notification/NCNotification.swift

@@ -287,7 +287,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                         self.notifications.remove(at: index)
                     }
                     self.tableView.reloadData()
-                    if self.navigationController?.presentingViewController != nil, notification.app == NCGlobal.shared.twofactorNotificatioName {
+                    if self.navigationController?.presentingViewController != nil, notification.app == NCGlobal.shared.twoFactorNotificatioName {
                         self.dismiss(animated: true)
                     }
                 } else if error != .success {