Search code examples
facebook-messenger-bot

MessengerExtensions.requestCloseBrowser() won't close in desktop


When i try to close the webview with this code:

MessengerExtensions.requestCloseBrowser(function success() {}, function failure(err) {
  alert('error closing the window: ' + err); // error closing the window: 
  console.log(err); // doesn't print
  window.close();
});

it closes the webview in iOS, but pops an alert when i try from desktop. My domain is white-listed, messenger_extensions = true and i enter the page from the desktop messenger and it still doesn't work.

I had before the same problem, but opposite (window closed on desktop, but not on iOS) while trying to use fetch(), and this problem started when started using $.ajax() before MessengerExtensions.requestCloseBrowser() was invoked from a fetch's promise, and now it's invoked from ajax's success function.

I had to switch fetch with ajax because it didn't work on iOS

Any suggestions?


Solution

  • A day later an error code of 2071011 started to show up, again, only in desktop browsers. I managed to find a workaround the problem by using window.top.close(); when MessengerExtensions.requestCloseBrowser() fails It does the same trick on Chrome and asks the user before close on Edge