Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to synchronize cookie between native and DWKWebView ? #28

Open
wendux opened this issue Feb 7, 2018 · 0 comments
Open

How to synchronize cookie between native and DWKWebView ? #28

wendux opened this issue Feb 7, 2018 · 0 comments
Labels

Comments

@wendux
Copy link
Owner

wendux commented Feb 7, 2018

There are two ways to do this:

  1. With JavaScript

    NSString * script=@"document.cookie=\"uname=xx; uid=34\"";
    [dwebview evaluateJavaScript:script completionHandler:nil];
  2. With fly.js

    Actually, fly.js can't support synchronizing Cookies between native and DWKWebView, but it supports forwarding the http request to Native through any Javascript bridge, and fly.js has already provide the dsBridge adapter. Suppose that all HTTP requests will be sent out on native side, there's no longer need to sync Cookies to DWKWebView. all you need to do is implementing a API named onAjaxRequest in default API namespace :

    /**
     * Note: This method is for Fly.js
     * In browser, Ajax requests are sent by browser, but Fly can
     * redirect requests to native, more about Fly see  https://github.com/wendux/fly
     * @param requestInfo passed by fly.js, more detail reference https://wendux.github.io/dist/#/doc/flyio-en/native
     */
    -(void)onAjaxRequest:(NSDictionary *) requestInfo  :(void (^)(NSString * _Nullable result,BOOL complete))completionHandle{
       
    }

    More details please refer to:

    1. https://wendux.github.io/dist/#/doc/flyio-en/redirect
    2. https://wendux.github.io/dist/#/doc/flyio-en/native
@wendux wendux added the RT label Feb 7, 2018
@wendux wendux changed the title How to synchronize Cookies between native and DWKWebView ? How to synchronize cookie between native and DWKWebView ? Feb 8, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant