Browse Source

improvements (#2591)

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 year ago
parent
commit
29a005cb85

+ 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 () -> Void) {
-        completion()
+    func nextcloudPushNotificationAction(data: [String: AnyObject]) -> [String: AnyObject]? {
+        return data
     }
 
     // class: AppDelegate

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -4670,7 +4670,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 6;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -4735,7 +4735,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 6;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;

+ 22 - 25
iOSClient/AppDelegate.swift

@@ -439,36 +439,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
 
     func nextcloudPushNotificationAction(data: [String: AnyObject]) {
-        NCApplicationHandle().nextcloudPushNotificationAction(data: data) {
 
-            var findAccount: Bool = false
+        guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data) else { return }
+        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 let accountPush = data["account"] as? String {
+            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: { })
             }
         }
     }