React Native Firebase动态链接iOS

时间:2018-10-17 05:46:43

标签: ios react-native firebase-dynamic-links react-native-firebase

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

更新

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

0 个答案:

没有答案