-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save all retrieved cookies and get cookies using javascript #18
base: master
Are you sure you want to change the base?
Save all retrieved cookies and get cookies using javascript #18
Conversation
kheldiente
commented
May 21, 2020
•
edited
Loading
edited
- Cache all retrieved cookies.
- Fixes Missing cookie values in iOS 10 or lower #17 where clients using iOS 10 or lower have missing cookie values.
5addbc6
to
cba1960
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a separate value called recordCookies,
store the cookie values in HTTPCookieStorage
In the service, it would be better to know through callback(onUpdateCookieStroage).
@@ -33,6 +33,8 @@ open class WKCookieWebView: WKWebView { | |||
// The closure where cookie information is called at update time | |||
@objc public var onUpdateCookieStorage: ((WKCookieWebView) -> Void)? | |||
|
|||
@objc public var recordedCookies: [HTTPCookie] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables managed only internally
I think private would be better than public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ;
@objc public func deleteRecordedCookie(_ cookie: HTTPCookie) { | ||
recordedCookies.removeAll(where: { $0.name == cookie.name }) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also public -> private and remove @objc
Hi @Kofktu , as per testing on my end, setting cookies to HTTPCookieStorage does not work in iOS 10 or lower. I believe this has something to do with evaluateDocumentCookies(webView: WKWebView) having dummy properties in cookies. Also, this validates the intention for storing it in a dedicated array and enabling clients to browse all cookies retrieved by WKCookieWebView, hence it is public. For deleteRecordedCookie(_ cookie: HTTPCookie), I'll remove that one. Commit for improvement is here. |