"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 allows to implement back navigation from your app without using the widget's "Back" button. When on home page the embedded component sends a "close" event . See Close event



// post a message with name 'dismiss' to the iframe when a button is clicked 

frame.contentWindow.postMessage({name: "dismiss"}, "*")

// inject the code below into the webview when a button is clicked

(function() {
 if (window.listenToEvent) {
 window.listenToEvent('dismiss', {});
}
})()


**Code sample **


<div>
 <button id="backButton">Back</button>
</div>

<script>
document.getElementById("backButton").onclick = () => {
const frame = document.getElementById("id-of-your-iframe")
frame.contentWindow.postMessage({name: "dismiss"}, "*")
}
</script>

// 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} />
</>
)
}