Browse Source

#1571

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
851e665e69
2 changed files with 16 additions and 0 deletions
  1. 1 0
      iOSClient/NCGlobal.swift
  2. 15 0
      iOSClient/Viewer/NCViewer.swift

+ 1 - 0
iOSClient/NCGlobal.swift

@@ -100,6 +100,7 @@ class NCGlobal: NSObject {
     // Name
     //
     @objc let appName                               = "files"
+    @objc let talkName                              = "talk-message"
     
     // Nextcloud version
     //

+ 15 - 0
iOSClient/Viewer/NCViewer.swift

@@ -47,6 +47,21 @@ class NCViewer: NSObject {
         // URL
         if metadata.classFile == NKCommon.typeClassFile.url.rawValue {
 
+            // nextcloudtalk://open-conversation?server={serverURL}&user={userId}&withRoomToken={roomToken}
+            if metadata.name == NCGlobal.shared.talkName {
+                let pathComponents = metadata.url.components(separatedBy: "/")
+                if pathComponents.contains("call") {
+                    let talkComponents = pathComponents.last?.components(separatedBy: "#")
+                    if let roomToken = talkComponents?.first {
+                        let urlString = "nextcloudtalk://open-conversation?server=\(appDelegate.urlBase)&user=\(appDelegate.userId)&withRoomToken=\(roomToken)"
+                        if let url = URL(string: urlString), UIApplication.shared.canOpenURL(url) {
+                            UIApplication.shared.open(url)
+                            return
+                        }
+                    }
+                }
+            }
+
             if let url = URL(string: metadata.url) {
                 UIApplication.shared.open(url)
             }