firebase / FirebaseUI-Flutter

Apache License 2.0
99 stars 86 forks source link

🐛 [firebase_ui_auth] "Magic Link" AuthStateChangeAction<SignedIn> not being fired #31

Open FuadEfendi opened 1 year ago

FuadEfendi commented 1 year ago

Bug report

Describe the bug Official example at firebase/flutterfire/packages/firebase_ui_auth/example/main.dart does not work: clicking the link in iPhone 14 Simulator "Safari" application accessing Gmail shows error message, and the callback AuthStateChangeAction not being fired

I am using updated "master" branch today, with all recent changes, but I initially noticed this issue weeks ago. Finally resolved by "workaround" (see below).

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to firebase/flutterfire/packages/firebase_ui_auth/example/main.dart
  2. add debug line 252 `print("successfully signed in");(see screenshot)
  3. run with iPhone 14 Pro iOS 16.2 simulator
  4. try to use "Sign in with magic link"
  5. Open "Safari", access GMail, click the link (see screenshot)
  6. Redirect error message in Safari (see screenshot)

Expected behavior

  1. After clicking Email "magic link" from the mobile device, Example application should automatically open and redirect to "/" route
  2. AuthStateChangeAction being fired
  3. Android Studio console should show debug message "successfully signed in"

Sample project

Official firebase/flutterfire/packages/firebase_ui_auth/example/main.dart with one-line debug message change (see attached)


Additional context

Note that I was able to fix this issue by workaround: FirebaseAuth.instance.authStateChanges().listen((user) { if (FirebaseAuth.instance.currentUser != null) { Get.offAllNamed(HomeScreen.routeName); } });

Note also that example application will be already authenticated, but to find this you need to explicitly close it and open again.

Please provide also step-by-step guide on how to configure IOS and Android to make it work: <key>FirebaseDeepLinkPasteboardRetrievalEnabled</key> and etc.; it is not documented at all with the example application, including necessary Firebase "dynamic links", App Store, and other settings. README.md has only 17 lines but we need detailed step-by-step guide.

Thank you!

Simulator Screen Shot - iPhone 14 Pro - 2023-02-28 at 09 32 55

Simulator Screen Shot - iPhone 14 Pro - 2023-02-28 at 09 28 04

Screenshot 2023-02-28 at 9 56 00 AM
darshankawar commented 1 year ago

Thanks for the detailed report @FuadEfendi A similar behavior has already been reported and acknowledged in this issue: https://github.com/firebase/FirebaseUI-Flutter/issues/41 and https://github.com/firebase/FirebaseUI-Flutter/issues/41

The error you are getting after validating the email doesn't seem to be specific to magic link, but with sign in with email link as well.

Take a look at below comment from team member and see if it helps in your case:

There is a chance that something has changed in the underlying package or apple-specific configuration.
Make sure you pass a correct ActionCodeSettings and configure your app according to [this documentation](https://firebase.google.com/docs/dynamic-links/flutter/receive#apple_platforms)

An easy way to verify that everything is configured correctly is to create a dynamic link and try to handle it with firebase_dynamic_links package. If you are able to receive a link in your app with this package, but still can't get email verification working – this means the issue is indeed in the firebase_ui.

https://github.com/firebase/FirebaseUI-Flutter/issues/41

FuadEfendi commented 1 year ago

Hi @darshankawar

Everything apple-specific configured correctly since this workaround works perfectly in iOS, it reopens application right after clicking magic link in Email (from same mobile device):

FirebaseAuth.instance.authStateChanges().listen((user) { if (FirebaseAuth.instance.currentUser != null) { Get.offAllNamed(HomeScreen.routeName); } });

And I did research before reporting, I didn't find neither suggested workaround nor bug report mentioning AuthStateChangeAction<SignedIn> not being fired (which is in the title of this bug report). Plus, lack of documentation.

It is not about "invalid link" (which I found a lot of documentation); instead, it is about AuthStateChangeAction not being fired

darshankawar commented 1 year ago

Plus, lack of documentation.

It is not about "invalid link" (which I found a lot of documentation); instead, it is about AuthStateChangeAction not being fired

See if this resembles your case for lack of documentation

FuadEfendi commented 1 year ago

See if https://github.com/firebase/FirebaseUI-Flutter/issues/35 resembles your case for lack of documentation

README.md should provide application-specific settings.

Generic documentation (written by others than application example original authors) is not acceptable, it does not include application-specific settings, it is indeed generic.

P.S. Title of https://github.com/firebase/FirebaseUI-Flutter/issues/31 (this page) is [firebase_ui_auth] "Magic Link" AuthStateChangeAction not being fired firebase/FirebaseUI-Flutter#31, this is unique new ticket, not duplicate.

darshankawar commented 1 year ago

Thanks for the update and feedback.

/cc @lesnitsky

ospar0829 commented 1 month ago

the problem is that the UniversalScaffold in email_link_sign_in_screen.dart from the library is not wrapped in a FirebaseUIActions Widget like in the other sign-in screens.