Our application allows logging in via SSO, which we do by firing up a WKWebKit view to a particular URL that communicates to our server, and eventually redirects to a URL that we are expecting. During this process we get a cookie that we need to transfer to our SessionManager, however, when trying to get the cookies from the WKHTTPCookieStore, we don't always get the callback. Here is some code:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
let httpCookieStore = WKWebsiteDataStore.default().httpCookieStore
httpCookieStore.getAllCookies { (cookies) in
// This block not always called!!!
}
}
This typically happens on initial install of the app on device, and is reproducible almost always on device, but not in the simulator.
At this point I have tried everything I can think of, but I don't know why the callback is sometimes called but not always.