React Native: ReactNativeWebview library
In React Native using the react-native-webview
library, pass the string ”ReactNativeWebView”
as the value of the eventHandlerName
parameter when creating an embedded session. Then pass an onMessage prop to your WebView to receive events published by the embedded UX:
<WebView
...
onMessage={(event) => {
handleEvent(event.nativeEvent.data);
}}
...
/>
When your callback receives an event, its event.nativeEvent.data
property will be a JSON string representing the event shape defined above.
For reference, you can look at this sample Expo Snack showing how to register an event handler and receive events.
Updated 24 days ago