capacitor-community / facebook-login

Facebook Login support
MIT License
103 stars 52 forks source link

Popup Blocked on Safari Iphone PWA #70

Closed shprink closed 2 years ago

shprink commented 2 years ago

Describe the bug

Hello, I used this cordova plugin before https://github.com/jeduan/cordova-plugin-facebook4 and switched to your's instead with capacitor v3.

Since I release the app, users on iOS or using safari desktop run into the "popup blocked" problem that is explained here: https://www.idownloadblog.com/2021/03/30/how-to-allow-pop-ups-in-safari/

The problem is that FacebookLogin.login gets stuck and never respond in the case popups are blocked (default setting).

How to handle this case? Is there a way to check if safari is setup correctly to allow FB login ?

thanks

To Reproduce Steps to reproduce the behavior:

  1. Open safari on iphone or desktop with popups blocked
  2. try to login

Expected behavior

Get an Error to let the developers know that something got wrong and it is because of safari's setting.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

ngochiep30051998 commented 2 years ago

I'm having the same problem.

rdlabo commented 2 years ago

Sorry, I don't know. This plugin is only wrapper: https://github.com/capacitor-community/facebook-login/blob/master/src/web.ts#L60-L80

Please check Facebook SDK. Thanks.

shprink commented 2 years ago

@rdlabo I found the reason. This is due to Safari refusing to open a popup window if called asynchronously.

unfortunately FB.login is wrapped into a Promise here https://github.com/capacitor-community/facebook-login/blob/master/src/web.ts#L59

Have you ever tried this plugin in safari @rdlabo ?

I found a workaround: I used FB.login directly into my code and use the callbacks instead of wrapping it into a Promise as you do here.

This needs to be reopened IMO

WilliamFischer commented 1 year ago

Why is this closed? The issue persists and is directly caused by this plugins implementation of the Facebook SDK.

@rdlabo Why not update the 'facebook SDK wrapper' code to use callbacks as suggested by @shprink, allowing this plugin to work in Safari on mobile?