Skip to content

Commit

Permalink
Merge pull request pichillilorenzo#9 from jj-lin/TWECACAPP-547-iOS12-…
Browse files Browse the repository at this point in the history
…set-cookie-no-completion

Solve the no set cookie completionHandler not called issue
  • Loading branch information
eJamesLin authored and GitHub Enterprise committed Jun 15, 2020
2 parents 00594ae + efdca48 commit dc65c54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/Classes/MyCookieManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ class MyCookieManager: NSObject, FlutterPlugin {
MyCookieManager.httpCookieStore!.setCookie(cookie, completionHandler: {() in
result(true)
})

// The `completionHandler` of WKHTTPCookieStore's `setCookie` not called at iOS11 ~ iOS12
// The following code could ensure the `completionHandler` will be called after cookie setup.
// ref: https://forums.developer.apple.com/message/309275
// ref: https://bugs.webkit.org/show_bug.cgi?id=185483
guard #available(iOS 13.0, *) else {
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: [WKWebsiteDataTypeCookies]) { _ in }
return
}
}

public static func getCookies(url: String, result: @escaping FlutterResult) {
Expand Down

0 comments on commit dc65c54

Please # to comment.