"Back" navigation action
The "Back" navigation action can be sent to the embedded component to allow navigation within the component from any app
The embedded component comes with a window.listenToEvent method which can be used to pass a "Back" navigation action to embedded components, this allows to implement back navigation from your app without using the widget's "Back" button.
Injecting the code below into the webview (or iframe) when a button is clicked navigates the widget back
(function() {
if (window.listenToEvent) {
window.listenToEvent('dismiss', {});
}
})()When the listenToEvent method is fired
- When not on home page: the embedded component navigates back in it's history
- When on home page the embedded component sends a "close" event . See Close event
**Code sample **
// create the script
const dismissScript = `
(function() {
if (window.listenToEvent) {
window.listenToEvent('dismiss', {});
}
})()
`
const YourApp = ()=> {
const webviewRef = useRef()
const handleBackPress = () => webViewRef.current.injectJavaScript(dismissScript);
return(
<>
<WebView ref = {webviewRef} />
<Button onPress={handleBackPress} />
</>
)
}
Updated 4 days ago
