NangoHQ / nango

A single API for all your integrations.
https://www.nango.dev
Other
4.51k stars 408 forks source link

Popup won’t open on Mobile Safari #2189

Open parisetflorian opened 3 months ago

parisetflorian commented 3 months ago

Triggering the auth workflow on mobile safari won’t open the popup.

linear[bot] commented 3 months ago

NAN-1007 Popup won’t open on Mobile Safari

bastienbeurier commented 3 months ago

Is this still happening?

parisetflorian commented 3 months ago

@bastienbeurier Yes! I just tested right now. Works fine on chrome but I get this on Safari: TypeError: null is not an object (evaluating 'this.modal.location = this.url + '&ws_client_id=' + wsClientId')

henrymgarrett commented 2 months ago

@parisetflorian What safari version and iOS version/phone are you on?

GeKorm commented 2 months ago

Hi! I suspect the problem is that this window.open() call happens in an async context when the AuthorizationModal is instantiated in a Promise. Most browsers block window.open if it's not a result of direct user interaction, but Safari iOS is especially strict about it. I've even found it problematic in sync contexts when it was a couple functions deep in a click handler.

Even after a potential fix for the Promise, it might be necessary to educate users about this, which is why some SDKs may provide a controlled button, or allow users to pass a reference to their own button and attach an event listener to it, eg:

const nango = new Nango({ publicKey: '<PUBLIC-KEY>', authButtonId: '<github-login>' });