如何在ReactNative中从WebView获取cookie?

时间:2019-02-26 05:00:58

标签: android ios reactjs react-native

我正在尝试从WebView的{​​{1}}获取cookie,但是在尝试从ReactNative获取cookie时却得到“未定义”。有任何指示/建议吗?

这是我的url代码:

ReactNative

这里相当于 render() { return ( <WebView source={{ uri: this.state.url }} thirdPartyCookiesEnabled={true} onNavigationStateChange={this._onNavigationStateChange.bind(this)} style={{marginTop: 20}} /> ); } _onNavigationStateChange(webViewState) { let url = webViewState.url; if (url.endsWith("/LoggedIn.htm")) { console.log("Logged In!"); this.loadDashboardURL(); } else if (url.endsWith("/dashboard.htm")) { console.log("Dashboard Loaded!"); console.log(url.cookies); <-- Getting UNDEFINED. } } ,可以正常工作:

Android

0 个答案:

没有答案