Posts

Post not yet marked as solved
29 Replies
51k Views
Hi,Anyone else having issues with WKWebView cookies after iOS 11.3? (Or any recomondations of what we might be doing wrong?)Working on an app with web content, we switched fro UIWebView to WKWebView after iOS 11.We use URLSession for authentication, then webviews to show content.In order to syncrhonzie cookies to WKWebViews, we have used the following procedure:1. Log in with URLSession2. Create a WKWebView with the cookies from the URLSession:let config = WKWebViewConfiguration() config.processPool = WKProcessPool() let cookies = HTTPCookieStorage.shared.cookies ?? [HTTPCookie]() cookies.forEach({ config.websiteDataStore.httpCookieStore.setCookie($0, completionHandler: nil) }) let wkWebView = WKWebView(frame: bounds, configuration: config) ...3. Load the URL.Worked like a charm, until iOS 11.3.Something fishy is happening, I have checked that the HTTPCookieStorage contains the correct cookies, and verified that the completionHandler of "setCookie" gets called before the url loads. However, the cookies are not being set.But. If we wait with creating the WKWebView/transfering cookies by about ~3 seconds after loggign in, it seems to work.This might seem like a bug introduced in iOS 11.3 (?), or any other suggestions?
Posted
by boedev.
Last updated
.