Search code examples
javascriptphpfacebookmobilehomescreen

Home screen app (android) facebook login opens browser


I'm working on a website that is focused on mobile users and uses a manifest to be opened standalone when added to the home screen. This works well, except for the Facebook login function. Whenever I try to login it opens the Facebook link in the browser outside the app. I then have to manually return to the app and reload the page to be logged on.

How can I stay inside the standalone app when logging in?

I tried using window.location as explained in this popular answer but no change. I also tried using window.open as explained here but again, no luck.

You can try it on this test page that has an adjusted manifest and login option to stay inside the test page. I used a Samsung Galaxy S5 for testing.


Solution

  • You should not stay inside your app while logging.

    Redirecting the user to the Identity provider (Facebook) in your case it is the normal life-cycle of an Oauth2 login or Single Sign On login. On the OAuth2 server you can set the redirect url which is the address you want the user to be send after login.

    https://developers.facebook.com/docs/facebook-login/web#redirecturl

    Login to your facebook app account: https://developers.facebook.com/apps and change the redirect url from your app control panel.