Closing the Webview
It's a good idea to close the webview after a transaction is complete, especially if actions the user took will result in a message in the thread.
There are two ways to do this:
Closing via Messenger Extensions
MessengerExtensions.requestCloseBrowser() will close the webview. You may want to do this after a transaction or flow is completed.
<script>
MessengerExtensions.requestCloseBrowser(function success() {
}, function error(err) {
});
</script>
Params
| Param | Description | Type | Required |
|---|---|---|---|
success callback | This function will be called if | function | Yes |
error callback | This function will be called if there is an error. | function | Yes |
Closing via Redirect
You can also redirect the user to a URL with the following format:
https://www.messenger.com/closeWindow/?image_url=IMAGE_URL&display_text=DISPLAY_TEXT
The text and image specified as parameters will be displayed briefly until the window closes. This will close only if you redirect from your URL/Page. Direct opening of URL will not close the browser.
This only works on Android. On iOS, the text and image will be displayed, but the browser will not close automatically.
| Param | Description | Type | Required |
|---|---|---|---|
| Image to be displayed before closing. Image is rendered with width 72px and height 72px. | string | Yes |
| Text to be displayed before closing | string | Yes |