From c6cba056e41afb96e187992807942ce47c685bf4 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Tue, 26 Sep 2023 13:38:25 +0300 Subject: [PATCH] Prevent ElementX from intercepting links that it can't handle. Redirect them to the system browser --- ElementX/Sources/Application/Application.swift | 7 ++++++- ElementX/Sources/Application/Navigation/AppRoutes.swift | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ElementX/Sources/Application/Application.swift b/ElementX/Sources/Application/Application.swift index 2a35c3a3a..7566bd15f 100644 --- a/ElementX/Sources/Application/Application.swift +++ b/ElementX/Sources/Application/Application.swift @@ -19,6 +19,7 @@ import SwiftUI @main struct Application: App { @UIApplicationDelegateAdaptor(AppDelegate.self) private var applicationDelegate + @Environment(\.openURL) private var openURL private let appCoordinator: AppCoordinatorProtocol init() { @@ -42,7 +43,11 @@ struct Application: App { return .systemAction }) - .onOpenURL { appCoordinator.handleDeepLink($0) } + .onOpenURL { + if !appCoordinator.handleDeepLink($0) { + openURL($0) + } + } .introspect(.window, on: .iOS(.v16)) { window in // Workaround for SwiftUI not consistently applying the tint colour to Alerts/Confirmation Dialogs. window.tintColor = .compound.textActionPrimary diff --git a/ElementX/Sources/Application/Navigation/AppRoutes.swift b/ElementX/Sources/Application/Navigation/AppRoutes.swift index 298c2f98a..494b083e1 100644 --- a/ElementX/Sources/Application/Navigation/AppRoutes.swift +++ b/ElementX/Sources/Application/Navigation/AppRoutes.swift @@ -83,6 +83,12 @@ struct ElementCallURLParser: URLParser { private let customSchemeURLQueryParameterName = "url" func route(from url: URL) -> AppRoute? { + // Element Call not supported, WebRTC not available + // https://github.com/vector-im/element-x-ios/issues/1794 + if ProcessInfo.processInfo.isiOSAppOnMac { + return nil + } + // First try processing URLs with custom schemes if let scheme = url.scheme, scheme == InfoPlistReader.app.elementCallScheme {