Explorar o código

Add url scheme for switching account

Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
Milen Pivchev %!s(int64=2) %!d(string=hai) anos
pai
achega
f87cbf37c8
Modificáronse 1 ficheiros con 18 adicións e 0 borrados
  1. 18 0
      iOSClient/AppDelegate.swift

+ 18 - 0
iOSClient/AppDelegate.swift

@@ -931,6 +931,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 }
             }
             return true
+
+        /*
+         Example:
+         nextcloud://open-and-switch-account?user=marinofaggiana&url=https://cloud.nextcloud.com
+         */
+
+        } else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-and-switch-account" {
+            guard let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false }
+            let queryItems = urlComponents.queryItems
+
+            guard let userScheme = CCUtility.value(forKey: "user", fromQueryItems: queryItems) else { return false }
+            guard let urlScheme = CCUtility.value(forKey: "url", fromQueryItems: queryItems) else { return false }
+
+            if getMatchedAccount(userId: userScheme, url: urlScheme) == nil {
+                return false
+            }
+
+            return true
         } else {
             let applicationHandle = NCApplicationHandle()
             let isHandled = applicationHandle.applicationOpenURL(url)