What I want to do: I make a fetch call, that gives me an API-token to login into a network. Now I want to inject a cookie (containing this api-token) into a Webview, so I should get logged in automatically.
What I tried: I set up a Webview like so:
<WebView
source={{uri:this.state.url}}
onNavigationStateChange={this._onNavigationStateChange.bind(this.url)}
javaScriptEnabled = {true}
injectedJavaScript={this.state.cookie}
/>
a little bit above I set cookie to:
cookie: 'document.cookie=\'apiToken=xxx; userId=1; expires=28799\'';
Also I loaded this chrome extension and injected the above line in Chrome and it works flawlessly..
I've read that the javascript gets injected after the view loaded, but this should still work, since I get redirected to 'domain/login', which should detect the cookie..
(I'm running react-native 0.29) Would appreciate any help.