Closed as not planned
Closed as not planned
Description
Issue
Hi All. I'm currently having issues with the email sign in link flow only on Android.
- iOS works perfectly fine and logs in as expected.
- Android fails after calling
auth().signInWithEmailLink
with the following Native error (no js error)
Given link is not a valid email link. Please use FirebaseAuth#isSignInWithEmailLink(String) to determine this before calling this function
The most confusing part is that I am calling auth().isSignInWithEmailLink(link)
before calling signInWithEmailLink
and it's returning true
. So tecnically rnfirebase is checking that it is a valid sign in link.
Any ideas on what I can be missing? I've already added sha-1 and sha-256 for both release an debug builds.
Something to note: I'm using build flavors, with three google-services.json files as shown on this library documentation.
This is the code that I'm using both to trigger the flow and for calling signInWithEmailLink
(removed the keys for privacy's sake)
On login:
<Button
mode="contained"
onPress={async () => {
await auth().sendSignInLinkToEmail(email', {
url: <<My registered deeplink url>>,
handleCodeInApp: true,
});
}}
>
To open the deeplink
const triggerEmailMagicLinkLogin = useCallback(async (link: string) => {
try {
setIsFirebaseLoading(true);
const isSigninLink = await auth().isSignInWithEmailLink(link); // <<- This one returns true so it should be a valid link.
if (!isSigninLink) return;
const result = await auth().signInWithEmailLink( // <<- This call throws.
email,
link
);
const token = await result.user?.getIdToken();
setIdToken(token);
} catch (error: any) {
if (error.code === 'auth/email-already-in-use') {
console.log('That email address is already in use!');
}
if (error.code === 'auth/invalid-email') {
console.log('That email address is invalid!');
}
setIsFirebaseError(true);
} finally {
setIsFirebaseLoading(false);
}
}, []);
useEffect(() => {
const getUrlAsync = async () => {
// Get the deep link used to open the app
const initialUrl = await Linking.getInitialURL();
if (initialUrl) {
triggerEmailMagicLinkLogin(initialUrl);
}
};
const eventListener = Linking.addEventListener('url', (event) => {
triggerEmailMagicLinkLogin(event.url);
});
getUrlAsync();
return () => {
eventListener.remove();
};
}, [triggerEmailMagicLinkLogin]);
Project Files
Javascript
Click To Expand
package.json
:
"@react-native-firebase/app": "20.1.0",
"@react-native-firebase/auth": "20.1.0",
firebase.json
for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile
:
- I'm not using Pods
- I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m
:
// N/A
Android
Click To Expand
Have you converted to AndroidX?
- my application is an AndroidX application?
- I am using
android/gradle.settings
jetifier=true
for Android compatibility? - I am using the NPM package
jetifier
for react-native compatibility?
android/build.gradle
:
// N/A
android/app/build.gradle
:
// N/A
android/settings.gradle
:
// N/A
MainApplication.java
:
// N/A
AndroidManifest.xml
:
<!-- N/A -->
Environment
Click To Expand
react-native info
output:
OUTPUT GOES HERE
- Platform that you're experiencing the issue on:
- iOS
- Android
- iOS but have not tested behavior on Android
- Android but have not tested behavior on iOS
- Both
react-native-firebase
version you're using that has this issue:e.g. 5.4.3
Firebase
module(s) you're using that has the issue:e.g. Instance ID
- Are you using
TypeScript
?Y/N
&VERSION
- 👉 Check out
React Native Firebase
andInvertase
on Twitter for updates on the library.
Activity