CRAlpha / react-native-wkwebview

WKWebview Component for React Native
MIT License
642 stars 271 forks source link

Improves sendCookie handling #50

Open insraq opened 7 years ago

insraq commented 7 years ago

This issue will probably take some time. We are not actively working on it (since we don't really use this). So any contribution is welcome. This will address some of the issues in PR #49.

  1. sendCookie should actually synchronize the cookies from NSHTTPCookieStorage to document.cookie. This will enable AJAX requests to share the cookie. You can simply use document.cookie = newCookie; to set/update cookies.
  2. Add a new prop like updateCookie to force an update from Set-Cookie header to NSHTTPCookieStorage. I believe Set-Cookie will eventually end up in NSHTTPCookieStorage, it's just a matter of when.
  3. Maybe also expose webView:decidePolicyForNavigationResponse:decisionHandler: and WKUserScript.
jacquescrocker commented 7 years ago

Any thoughts on this? https://github.com/CRAlpha/react-native-wkwebview/pull/67

I'm using WkWebView to reuse my website's authentication system (fairly complex and cant easily be extracted into an api / oauth flow). So I'll need to watch and pull out a cookie from the environment once the user is logged in.

wireforce commented 7 years ago

Maybe instead of patching the current WKWebView we can implement proper cookie-handling in this component, when iOS11 is out. With iOS11 Apple seems to have added the proper tools to handle cookies:

https://developer.apple.com/documentation/webkit/wkhttpcookiestore (info video: https://developer.apple.com/videos/play/wwdc2017/220/)

insraq commented 6 years ago

@wireforce I agree we should implement WKHTTPCookieStore. Feel free to make a PR if you are interested.

wireforce commented 6 years ago

After the v1.17.0 release this component actually works fine for my use case (Several webviews that needs to share the session cookies and local storage). I cant grab the cookies that are set in the webviews (as I would if WKHTTPCookieStore was used), but I don't need to do that right now. So I'm happy :)