【发布时间】:2020-04-27 20:32:00
【问题描述】:
我已在我的 react-native 应用中从 firebase 启用 signInWithEmailLink()。
一切正常,用户也已创建,但我认为onLink(handleLink) 侦听器被多次触发,即使在用户登录后也会导致错误。
日志:
link is tru
LOG email: email@gmail.com //I have hidden the actual email
LOG email: email@gmail.com
LOG email: email@gmail.com
LOG USer created
LOG EROR: [Error: [auth/invalid-action-code] The out of band code is invalid. This can happen if the code is malformed, expired, or has already been used.]
LOG EROR: [Error: [auth/invalid-action-code] The out of band code is invalid. This can happen if the code is malformed, expired, or has already been used.]
LOG EROR: [Error: [auth/invalid-action-code] The out of band code is invalid. This can happen if the code is malformed, expired, or has already been used.]
您可以看到它多次触发,我该如何防止这种情况发生??
这是我的代码:
const handleLink = async link => {
console.log('opened Link: ', link.url);
if (auth().isSignInWithEmailLink(link.url)) {
console.log('link is tru');
try {
const email = await AsyncStorage.getItem('email');
console.log('email: ', email);
await auth()
.signInWithEmailLink(`${email}`, link.url)
.then(() => {
console.log('USer created');
})
.catch(err => {
console.log('EROR: ', err);
});
} catch (err) {
console.log('err: ', err);
}
} else {
console.log('link is false');
}
};
const link = dynamicLinks().onLink(handleLink);
非常感谢您的帮助
【问题讨论】:
标签: react-native firebase-authentication firebase-dynamic-links react-native-firebase