sahat / satellizer

Token-based AngularJS Authentication
https://satellizer-sahat.rhcloud.com
MIT License
7.85k stars 1.13k forks source link

window.open blocked in Facebook/Messenger in-app browser #810

Open subpublic opened 8 years ago

subpublic commented 8 years ago

We are posting our registration page on facebook and messenger apps, but the loginbutton doesn't work on iOS. It works fine if opened in Safari.

My guess is that the in-app browser is blocking popups.

Anyone else with this problem? Solutions? I'm thinking maybe using a fullscreen iframe instead of window.open.

I'm using version 0.13.1

subpublic commented 8 years ago

The in-app browser actually opens the page (doesn't block it), but not in another window. It just goes forward so the polling stops and isn't possible to bli closed by satellizer.

garrettlangley commented 8 years ago

@subpublic what did you wind up doing here?

subpublic commented 8 years ago

We wounded up detecting iphone FB-apps and saving our login details in localStorage. And when returning to the redirectUrl we check the localStorage if anything is saved, here calling the same registration as we do after the regular satellizer login.

This detects both FB and Messenger app in iphone (android doesn't have the problem)

if (navigator.userAgent.match(/iPhone/i) && navigator.userAgent.match(/FBMD/i)) {
garrettlangley commented 8 years ago

but @subpublic how did you avoid the the popup? did you do an iframe?

subpublic commented 8 years ago

No need to, it doesn't open any popup, it just opens the loginprovider (fb/google/etc) in the same window. Kind of the same solution as if we didn't use satellizer at all.

garrettlangley commented 8 years ago

so did you fork satellizer and make changes? or just drop satellizer entirely?

subpublic commented 8 years ago

No, it's no real solution in satellizer. Just needs do be handled separately. Still using satellizer when not in iphone/fb.

kirill-sokolov commented 8 years ago

@subpublic

I have same problem as you. I do login via satellizer and it works on desktops, but on iPad it does not: Facebook popup opens, i enter my credentials in it, after subit it just closes and nothing happens. My function:

function authenticate(provider) {
    console.log(provider);
    return $auth.authenticate(provider);
}

I can see console.log dump with "facebook" before auth.

MyService
    .authenticate(provider) // this returns $auth.authenticate() promise
    .then(onAuthSuccess)
    .catch(onAuthError);

onAuthSuccess and onAuthError are called only on desktops, but not on mobile devices ( tested on Ipad IOS9 Safari )

bmarotta commented 4 years ago

@subpublic : Could you please publish somewhere a full code snippet of your workaround?