首页 > 解决方案 > React Native Firebase 动态链接 iOS

问题描述

我正在尝试使用 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);
  }
}

我可以在 Android 中使用 apiKey 检索长电子邮件链接url。但是在 iOSurl中只是来自 的重定向 url actionCodeSettings,所以isWithEmail永远都是false. 我在我的代码中做错了吗?

url在安卓中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];
}

更新

没关系。只需要将关联域更改为默认动态链接

标签: iosreact-nativefirebase-dynamic-linksreact-native-firebase

解决方案


推荐阅读