0

Facebook Messenger has MessengerExtensions.requestCloseBrowser that will close the webview on the Messenger app. Is there an equivalent for Google Assistant?

The use case might be authenticating or completing some type of acquisition and closing the webview out.

I tried various window.close() methods, but they just get ignored.

Ian Smith
  • 91
  • 1
  • 8
  • Here's the Facebook webview API for reference. https://developers.facebook.com/docs/messenger-platform/webview – Ian Smith Oct 25 '17 at 13:40
  • 2
    Under what scenarios are you getting a webview that you control through the Assistant? – Prisoner Oct 25 '17 at 14:08
  • I'm exploring supplemental authentication methods in the context of the chat flows such as a quick PIN that dismisses after the PIN has been entered and authenticated. Having a success message with "Click the close link above" would be a bad user experience. The FB Messenger docs also convey, "It is 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. This can be done with the Messenger Extensions SDK or by using a redirect URL." – Ian Smith Oct 25 '17 at 20:26
  • The authentication flow has the ability to open up a web view, but I don't think you can open one up yourself directly. – Wayne Piekarski Oct 28 '17 at 00:13

1 Answers1

0

Well, I have some bad news, some good news, and some bad news.

First of all, I'm assuming you're opening the web view through the use of a card that links to the page in question. Right?

First bad news: you can't use window.close()

The Javascript window.close() function doesn't do what it used to do. It only closes windows that it opens. Since it was opened elsehow, you can't use this method.

Some good news, sort-of

You can, however, use something like history.back() to back out of the page. If you have only one page in the history, then this will back out of the web view and back into the Assistant.

It won't, however, let you generate another response through the Assistant. So while they might be authenticated, you can't send anything telling them that (at least not in the Assistant), until they say something back to you.

Facebook seems to sort-of allow this through their URL trick, but this is a trick, and it doesn't seem to work on all their platforms.

But the real bad news is...

Even if you can find a technical solution, you can't do this for the reason you're trying to.

Google's term's don't allow you to do any other kind of authentication except through Account Linking. Specifically it says:

Don't use any other method to associate a Google user with an account on your system

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thanks for responding. Some comments... - history.back() does not seem to do anything. Did you try it yourself? - The Facebook API allows a redirect, but also an explicit JavaScript function via their MessengerExtensions API. I tried it on native and web and it works fine, so I don't think it's a hack. – Ian Smith Nov 02 '17 at 19:53
  • Perhaps you can help me think of a different way fundamentally to approach all of this. One way of looking at authentication is to Google. I'm not trying to reinvent that. In a hypothetical scenario, you could imagine changing the address for an expensive delivery. You may be logged into Google, but you probably also want to make sure they're logged into your business app before letting them do that via Assistant since there's no auth to get into Assistant in the first place after the initial login. Just because you're authed to Google doesn't mean you're authed to your business. – Ian Smith Nov 02 '17 at 19:54
  • @IanSmith I tried using Facebook's redirect to close my webview, but it does not close it. it just gets redirected to that url and stops showing the image and the display text. Is there any other way to close the window on google assistant? – zoram Feb 24 '18 at 10:03