i need to use same configuration (cookie) on the second WebView after the user is authorized on first WebView. On simulator it's work well, but on device is not stable.
class auth: UIViewController, WKNavigationDelegate, UIWebViewDelegate {
private var webView: WKWebView = WKWebView()
override func viewDidLoad() {
super.viewDidLoad()
webView.navigationDelegate = self
loadPage(urlString: link)
}
private func loadPage(urlString: String) {
if let encodedURL = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: encodedURL) {
let request = URLRequest(url: url)
webView.refreshCookies()
webView.load(request)
}
}
}
extension WKWebView {
func refreshCookies() {
self.configuration.websiteDataStore = WKWebsiteDataStore.default()
}
}