mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fixes #1824 - Redirect universal links directly to the browser if they're not supported
This commit is contained in:
@@ -45,7 +45,7 @@ struct Application: App {
|
|||||||
})
|
})
|
||||||
.onOpenURL {
|
.onOpenURL {
|
||||||
if !appCoordinator.handleDeepLink($0) {
|
if !appCoordinator.handleDeepLink($0) {
|
||||||
openURL($0)
|
openURLInSystemBrowser($0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.introspect(.window, on: .supportedVersions) { window in
|
.introspect(.window, on: .supportedVersions) { window in
|
||||||
@@ -57,8 +57,32 @@ struct Application: App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Private
|
||||||
|
|
||||||
|
/// Hide the status bar so it doesn't interfere with the screenshot tests
|
||||||
private var shouldHideStatusBar: Bool {
|
private var shouldHideStatusBar: Bool {
|
||||||
ProcessInfo.isRunningUITests
|
ProcessInfo.isRunningUITests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// https://github.com/vector-im/element-x-ios/issues/1824
|
||||||
|
/// Avoid opening universal links in other app variants and infinite loops between them
|
||||||
|
private func openURLInSystemBrowser(_ originalURL: URL) {
|
||||||
|
guard var urlComponents = URLComponents(url: originalURL, resolvingAgainstBaseURL: true) else {
|
||||||
|
openURL(originalURL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var queryItems = urlComponents.queryItems ?? []
|
||||||
|
queryItems.append(.init(name: "no_universal_links", value: "true"))
|
||||||
|
|
||||||
|
urlComponents.queryItems = queryItems
|
||||||
|
|
||||||
|
guard let url = urlComponents.url else {
|
||||||
|
openURL(originalURL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
openURL(url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<string>applinks:develop.element.io</string>
|
<string>applinks:develop.element.io</string>
|
||||||
<string>applinks:mobile.element.io</string>
|
<string>applinks:mobile.element.io</string>
|
||||||
<string>applinks:call.element.io</string>
|
<string>applinks:call.element.io</string>
|
||||||
|
<string>applinks:call.element.dev</string>
|
||||||
<string>webcredentials:*.element.io</string>
|
<string>webcredentials:*.element.io</string>
|
||||||
</array>
|
</array>
|
||||||
<key>com.apple.developer.usernotifications.communication</key>
|
<key>com.apple.developer.usernotifications.communication</key>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Redirect universal links directly to the browser if they're not supported
|
||||||
Reference in New Issue
Block a user