This repository was archived by the owner on Jun 7, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,21 +132,30 @@ extension WebBrowserApp {
132132 }
133133
134134 func open( url: URL ) {
135- guard let url = appSchemeURL ( forURL: url) else { return }
136-
137- switch self {
138- case . safari, . chrome, . opera, . firefox:
139- UIApplication . shared. open ( url)
140- case . inAppSafari:
141- func present( ) {
142- let controller = SFSafariViewController ( url: url)
143- UIWindow . topWindow. rootViewController? . present ( controller, animated: true , completion: nil )
135+ func openInBrowser( ) {
136+ guard let browserURL = appSchemeURL ( forURL: url) else { return }
137+
138+ switch self {
139+ case . safari, . chrome, . opera, . firefox:
140+ UIApplication . shared. open ( browserURL)
141+ case . inAppSafari:
142+ func present( ) {
143+ let controller = SFSafariViewController ( url: browserURL)
144+ UIWindow . topWindow. rootViewController? . present ( controller, animated: true , completion: nil )
145+ }
146+
147+ if Thread . isMainThread {
148+ present ( )
149+ } else {
150+ DispatchQueue . main. async ( execute: present)
151+ }
144152 }
153+ }
145154
146- if Thread . isMainThread {
147- present ( )
148- } else {
149- DispatchQueue . main . async ( execute : present )
155+ let options = [ UIApplication . OpenExternalURLOptionsKey . universalLinksOnly : true ]
156+ UIApplication . shared . open ( url , options : options ) { ( success ) in
157+ if !success {
158+ openInBrowser ( )
150159 }
151160 }
152161 }
You can’t perform that action at this time.
0 commit comments