我正在尝试检索用户输入的邮政编码,该邮政编码已添加到webview的cookie中。我如何得到它?我试过react-native-cookies哪个是空对象。
import CookieManager from 'react-native-cookies';
componentWillMount() {
CookieManager.get('https://www.example.com')
.then((res) => {
console.log('CookieManager.get from webkit-view =>', res);
});
}
}
<WebView
style={styles.webview}
source={{ uri: 'https://www.example.com' }}
injectedJavaScript={INJECTED_JAVASCRIPT}
mixedContentMode="compatibility"
javaScriptEnabled
domStorageEnabled
thirdPartyCookiesEnabled
sharedCookiesEnabled
originWhitelist={['*']}
useWebKit
/>
Run Code Online (Sandbox Code Playgroud)
我正在iOS模拟器中尝试。Android很棒。我看到https://github.com/react-native-community/react-native-webview/pull/175已合并,但无法弄清楚如何使用它来获取用户设置的cookie。
react-native react-native-ios react-native-webview react-native-cookies
我有一个在 web 视图中打开的单点登录网站。用户登录后,我需要使用 cookie 来从 API 请求令牌,并在应用程序中将其用于所有其他请求。这一切在 Android 上运行良好,但在 iOS 上,当我请求令牌时,没有 cookie。WebView 配置为使用共享 cookie 存储:
<WebView
source={{ uri: loginUrl }}
onMessage={handleSsoLogin}
injectedJavaScriptBeforeContentLoaded={JS_INTERFACE}
sharedCookiesEnabled={true}
/>
Run Code Online (Sandbox Code Playgroud)
如果我使用 devTools 检查 webView,我可以看到 cookie。另外,如果我再次访问 SSO 站点,我已经记录了它。因此,cookie 被 webView 保存和使用。它们只是不被使用fetch并且 CookieManager 不访问它们:
const cookies = await CookieManager.get(url);
console.log({ cookies });
...
{"cookies": {}}
Run Code Online (Sandbox Code Playgroud)
那么,问题来了,如何从webView中获取这些cookie呢?
react-native react-native-ios react-native-webview react-native-cookies
我正在尝试使用@react-native-community/react-native-video播放来自 CloudFront 的安全视频。
要重现视频,我必须设置 3 个 cookie:CloudFront-Key-Pair-Id、CloudFront-Policy 和 CloudFront-Signature。
我已经能够使用这个模块在 IOS 中重现视频:react-native-cookies
但我无法在 android 中重现视频。如何设置 cookie 来播放此视频?
该视频是 .m3u8 扩展名 (HLS)
非常感谢!
cookies video react-native react-native-video react-native-cookies