5

I am using Cookie Store Observer to to track changes in the cookies value on my webview. It was working fine on all versions of IOS. but since IOS 13.0 came out, this no longer works. I am not getting any call to

@available(iOS 11.0, *)
func cookiesDidChange(in cookieStore: WKHTTPCookieStore){
  cookieStore.getAllCookies { cookies in
  //Store cookies to UserDefaults on Background Thread
  DispatchQueue.global(qos: .userInitiated).async {
     self.storeCookies(cookies: cookies)
  }
 }
} 

I am setting cookie observer before the web-view is created.

WKWebsiteDataStore.default().httpCookieStore.add(self)

All of a sudden it stopped working from IOS 13.0. I havent noticed any change in docs around this API.

Anybody have any info on it on IOS 13.0?

Easy Coder
  • 295
  • 1
  • 3
  • 14
  • Did you manage to solve this? I'm seeing the same issue. – CPR Nov 26 '19 at 21:43
  • 1
    No, I haven't. Still got the issue. – Easy Coder Nov 27 '19 at 16:01
  • 2
    Thanks for the reply. I did extensive testing, and I'm convinced it's a bug. If I switch to iOS 11.4, the callback fires. On iOS 12.0+, it doesn't fire. I'll try and get round to filing a radar with Apple and see what they say. – CPR Nov 27 '19 at 16:08
  • Works for me on iOS 12, not on iOS 13. – Marcus Adams May 29 '20 at 19:41
  • Found a work around. Injected some Javascript to monitor the cookies and make a call back, using the Javascript from this answer. https://stackoverflow.com/a/14344716/168493 – Marcus Adams Jun 02 '20 at 17:01
  • interesting how the APIs apple design work like crap and have zero documentation. Apple should be ashamed of claiming "it just works". It may be true for consumer products but their APIs stink. – Duck Aug 17 '20 at 17:31
  • Any updates? I'm seeing some inconsistent behaviour from the cookie observing right now. Using iOS 14.4 (but it's there since 14.3 and possibly earlier). Sometimes the cookie changes are alerted through this observing object, but sometimes it seems like it's not called. I even double-checked that the cookie is in fact set by connecting the iPhone to my Mac and observing the web view page through Safari on my mac... – Jonny Jan 27 '21 at 08:38

0 Answers0