Setup
install react native webview package, the library wont work with the default webview
yarn install react-native-webview
install package
yarn install react-native-webview-bridge-seamless
make sure you import webview from react-native-webview
and not from react-native
import {WebView, WebViewSharedProps} from 'react-native-webview';
import {withWebViewBridge} from 'react-native-webview-bridge-seamless';
wrap the webview
export const WebViewWithBridge = withWebViewBridge(WebView);
Usage
Component<> { superprops; thisgetToken = thisgetToken; } async { if type === 'A' return await ; else return await ; } { return <WebViewWithBridge source=uri: 'https://your-page.io' reactNativeApi= getToken: thisgetToken /> }
inside your web application we can interact with the defined app in the following way
const timeout = 5000; // promise will fail if no response in 5 secondsconst tokenA = await window;