Close button in webview

(Vila Vg) #1

hi there

just curious if there’s a way to close a webview from within the webview by tapping on a close button so that the user can return to the messenger interface from where they started?

thanks!

(Daniel Beckett) #2

Hi Vila,

There should be a close button already showing on the webview window. There’s also a script that you could use if the webview is opening up a page that you control. There’s more info on that here.

Thanks,
Dan

(Vila Vg) #3

Hi Daniel

For the “Closing via Messenger Extensions” method Does that require whitelisting the domain and loading the Js library? For the second method Closing via Redirect, is it simply seems about having a page that has close button with a link to that redirect URL?

(Technical You) #4

I am too having a problem with this(close via redirect url)

(Daniel Beckett) #5

I’m a bit limited on what I can suggest here since the webview isn’t something we directly support :thinking:.

Based on the documentation provided by Facebook it looks like you will need a button on your webview page that runs the MessengerExtensions.requestCloseBrowser script, i.e.

<script>
      MessengerExtensions.requestCloseBrowser(function success() {
  
      }, function error(err) {
  
      });
</script>

For the redirect URL the method would likely be the same but instead of running a script you will point to the redirect URL with your button (or run it after a certain action on your page).

1 Like