Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

[NEW] Try to open links as an universal URL instead of directly on the browser #2590

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions Rocket.Chat/Managers/WebBrowserManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,30 @@ extension WebBrowserApp {
}

func open(url: URL) {
guard let url = appSchemeURL(forURL: url) else { return }

switch self {
case .safari, .chrome, .opera, .firefox:
UIApplication.shared.open(url)
case .inAppSafari:
func present() {
let controller = SFSafariViewController(url: url)
UIWindow.topWindow.rootViewController?.present(controller, animated: true, completion: nil)
func openInBrowser() {
guard let browserURL = appSchemeURL(forURL: url) else { return }

switch self {
case .safari, .chrome, .opera, .firefox:
UIApplication.shared.open(browserURL)
case .inAppSafari:
func present() {
let controller = SFSafariViewController(url: browserURL)
UIWindow.topWindow.rootViewController?.present(controller, animated: true, completion: nil)
}

if Thread.isMainThread {
present()
} else {
DispatchQueue.main.async(execute: present)
}
}
}

if Thread.isMainThread {
present()
} else {
DispatchQueue.main.async(execute: present)
let options = [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly: true]
UIApplication.shared.open(url, options: options) { (success) in
if !success {
openInBrowser()
}
}
}
Expand Down