You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my flutter android app, I have used firebase for authentication(Passwordless Authentication) and it sends email links perfectly to the given email address through the android emulator. Email link is similar as follows,
However, after clicking the link it redirects to the mobile app but does not handle isSignInWithEmailLink method. Becauseif(FirebaseAuth.instance.isSignInWithEmailLink(link.toString())) is always false.
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
if (state == AppLifecycleState.resumed) {
final PendingDynamicLinkData data =
await FirebaseDynamicLinks.instance.getInitialLink();
if (data?.link != null) {
_handleLink(data?.link);
}
FirebaseDynamicLinks.instance.onLink(
onSuccess: (PendingDynamicLinkData dynamicLink) async {
final Uri deepLink = dynamicLink?.link;
_handleLink(deepLink);
}, onError: (OnLinkErrorException e) async {
print('onLinkError');
print(e.message);
});
}
}
void _handleLink(Uri link) async {
try {print('==================1===================$link');
if (_auth.isSignInWithEmailLink(link.toString())) {
print('===================2==================');
final User user = (await _auth.signInWithEmailLink(
email: _userEmail,
emailLink: link.toString(),
))
.user;print('===================3==================$user');
if (user != null) {
setState(() {
_loginEmail = user.email;
_success = true;
});
} else {
setState(() {
_success = false;
});
}
} else {
setState(() {
_success = false;
});
}
} on PlatformException catch (e) {
if (e.code == 'ERROR_INVALID_ACTION_CODE') {
_success = false;
_errorMsg = 'Email link has been expired. Try again';
}
} catch (e) {
print(e);
}
setState(() {});
}
As per the implementation of isSignInWithEmailLink in Firebase, it only 'true' if the email link contains the following texts. Can anybody help me to solve this issue?
[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19041.928], locale en-US)
• Flutter version 2.0.6 at C:\src\flutter
• Framework revision 1d9032c7e1 (9 days ago), 2021-04-29 17:37:58 -0700
• Engine revision 05e680e202
• Dart version 2.12.3
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\Madusha\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = C:\Users\Madusha\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
[√] VS Code (version 1.56.0)
• VS Code at C:\Users\Madusha\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.22.0
[√] Connected device (3 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.93
• Edge (web) • edge • web-javascript • Microsoft Edge 90.0.818.51
• No issues found!
pubspec.yaml
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.7.0
firebase_analytics: ^7.0.1
firebase_auth: ^0.20.1
firebase_dynamic_links: ^0.7.0+1
google_fonts: ^1.0.0
google_sign_in: 4.0.7
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.1
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
In my flutter android app, I have used firebase for authentication(Passwordless Authentication) and it sends email links perfectly to the given email address through the android emulator. Email link is similar as follows,
https://fir-login-6f7da.firebaseapp.com/__/auth/action?apiKey=AIzaSyDlX7iyKLvh87ZrHgWLxvCjCtkTjXUeSm8&mode=signIn&oobCode=c9JvCxJbZyoPGRwhjAZmCTENDe-3aSnVZ3hxH8BRG0IAAAF5TvSkOA&continueUrl=https://mydynamic.page.link/V5Hh&lang=en
However, after clicking the link it redirects to the mobile app but does not handle isSignInWithEmailLink method. Because
if(FirebaseAuth.instance.isSignInWithEmailLink(link.toString()))
is always false.In the console, it prints like
==================1===================https://mydynamic.page.link/V5Hh
I am wondering why it should not print the whole email link (https://fir-login-6f7da.firebaseapp.com/__/auth/action?apiKey=AIzaSyDlX7iyKLvh87ZrHgWLxvCjCtkTjXUeSm8&mode=signIn&oobCode=c9JvCxJbZyoPGRwhjAZmCTENDe-3aSnVZ3hxH8BRG0IAAAF5TvSkOA&continueUrl=https://mydynamic.page.link/V5Hh&lang=en)
As per the implementation of isSignInWithEmailLink in Firebase, it only 'true' if the email link contains the following texts. Can anybody help me to solve this issue?
flutter doctor -v
pubspec.yaml
flutter run --verbose
Beta Was this translation helpful? Give feedback.
All reactions