I'm trying to use WebView for a page in my app but when trying to log into google I get an error. I am aware that google requires a known OS browser to log onto their services but there are ways around their OAuth. Where in my code should it be implemented to have google believe that WebView is a browser.
class CycleViewController: UIViewController, WKUIDelegate {
var window: UIWindow?
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
webView.backgroundColor = UIColor.clear
webView.backgroundColor = UIColor(red: 0.0196, green: 0.4, blue: 0.2902, alpha: 1.0)
webView.isOpaque = false
let myURL = URL(string: "https://jwelsh19.wixsite.com/countryday")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
Just set the correct value of your mobile safari agent in webConfiguration.applicationNameForUserAgent
. Try with the following code.
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.applicationNameForUserAgent = "Version/8.0.2 Safari/600.2.5"
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With