1
Hello, developing an app for IOS, but would like it to open with Google Chrome instead of Safari browser.
Could one of you help me?
Code:
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.naivgationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://site.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
guard let requestURL = navigationAction.request.url else {
decisionHandler(.allow)
return
}
//Aqui você tem a URL, e pode fazer o que quiser com ela.
decisionHandler(.allow)
}
}
Thanks for the answer George, I’ll test.
– Davi