Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get LocalStorage from WebView react native

import { WebView } from 'react-native-webview';

const INJECTED_JAVASCRIPT = `(function() {
  const tokenLocalStorage = window.localStorage.getItem('token');
  window.ReactNativeWebView.postMessage(tokenLocalStorage);
})();`;

export default function App() {
  const onMessage = (payload) => {
    console.log('payload', payload);
  };

  return (
    <View style={styles.container}>
      <StatusBar style="auto" />
      <WebView
        source={{ uri: 'https://somewebsite.com/login' }}
        injectedJavaScript={INJECTED_JAVASCRIPT}
        onMessage={onMessage}
      />
    </View>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery select self and siblings 
Javascript :: react link without underline 
Javascript :: stop interval js 
Javascript :: short if 
Javascript :: javascript pass parameter to event listener 
Javascript :: react index.jsx example 
Javascript :: javascript blob to file 
Javascript :: find all subsets of an array javascript 
Javascript :: orbit controls drei 
Javascript :: google sheets api javascript 
Javascript :: onclick change image src javascript 
Javascript :: flatten an array without using .flat(); 
Javascript :: $(window).scrolltop() not working on mobile 
Javascript :: jquery set hidden field value 
Javascript :: count json objects 
Javascript :: nodejs path 
Javascript :: how to customize js alert box 
Javascript :: cypress check attribute for each element 
Javascript :: sum all the values in an array javascript 
Javascript :: jquery on wheel event 
Javascript :: Vue.use is not a function 
Javascript :: modal show with jquery ready function 
Javascript :: input radio trigger select jquery 
Javascript :: get width of div jquery 
Javascript :: setinterval stop onditional stop 
Javascript :: jquery display modal bs4 
Javascript :: scrollto is not a function javascript 
Javascript :: express middleware logging 
Javascript :: javascript how to get middle letters of a string 
Javascript :: react hook form reset 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =