1import { WebView } from 'react-native-webview';
2
3const INJECTED_JAVASCRIPT = `(function() {
4 const tokenLocalStorage = window.localStorage.getItem('token');
5 window.ReactNativeWebView.postMessage(tokenLocalStorage);
6})();`;
7
8export default function App() {
9 const onMessage = (payload) => {
10 console.log('payload', payload);
11 };
12
13 return (
14 <View style={styles.container}>
15 <StatusBar style="auto" />
16 <WebView
17 source={{ uri: 'https://somewebsite.com/login' }}
18 injectedJavaScript={INJECTED_JAVASCRIPT}
19 onMessage={onMessage}
20 />
21 </View>
22 );
23}
24