我正在尝试使用RNFirebase通过电子邮件链接登录应用程序
signInWithDynamicLink = async url => {
const { dispatch, navigation } = this.props;
const isWithEmail = RNFirebase.auth().isSignInWithEmailLink(url);
if (isWithEmail) {
try {
dispatch(setSignInByEmail(true));
const signInEmail = await AsyncStorage.getItem('emailForLogin');
if (signInEmail) {
await RNFirebase.auth().signInWithEmailLink(signInEmail, url);
await AsyncStorage.removeItem('emailForLogin');
} else {
// Handle non sign in email link
}
} catch (error) {
console.log(error);
}
}
我可以使用url
中的apiKey检索长电子邮件链接,这在Android中也可以。但是在iOS中,url
只是来自actionCodeSettings
的重定向URL,因此isWithEmail
将始终为false
。我在代码中做错了吗?
url
在Android https://example.page.link/?link=https://project.firebaseapp.com/__/auth/...https://redirect-url.com%26lang%3Den
在iOS https://redirect-url.com
这是我的动态链接处理程序的AppDelegate.m
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<NSString *, id> *)options {
return [[RNFirebaseLinks instance] application:application openURL:url options:options];
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {
return [[RNFirebaseLinks instance] application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
}
更新
没关系。只需将关联域更改为默认动态链接