所以我的条件是,如果包含 URL,com://******/sendto/webview
那么它应该在我的应用程序内的浏览器中打开,否则它将在 Safari 中打开。我无法弄清楚我做错了什么?
if let url = homeObject["deeplink_url"] as? String, url != "" {
if url.contains("com://******/sendto/webview") {
if url.contains("?url") {
self.fixMalformedURL(url)
} else {
if let urlComponents = URLComponents(url: URL(string: url)!, resolvingAgainstBaseURL: true) {
let webViewTitle = urlComponents.queryItems!.filter({ $0.name == "title" }).first
let webViewURL = urlComponents.queryItems!.filter({$0.name == "url"}).first
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "FeaturedWebViewController") as! FeaturedWebViewController
vc.webViewTitle = webViewTitle!.value
vc.dynamicURL = webViewURL!.value
self.navigationController?.pushViewController(vc, animated: true)
}
}
} else {
UIApplication.shared.openURL(URL(string: url)!)
}
}