diff --git a/packages/auth/ios/RNFBAuth/RNFBAuthModule.m b/packages/auth/ios/RNFBAuth/RNFBAuthModule.m index 0e1ac88b86..c2531c7d22 100644 --- a/packages/auth/ios/RNFBAuth/RNFBAuthModule.m +++ b/packages/auth/ios/RNFBAuth/RNFBAuthModule.m @@ -1462,15 +1462,6 @@ - (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver { } #endif -- (NSString *)getJSFactorId:(NSString *)factorId { - if ([factorId isEqualToString:@"1"]) { - // Only phone is supported by the front-end so far - return @"phone"; - } - - return factorId; -} - - (void)promiseRejectAuthException:(RCTPromiseRejectBlock)reject error:(NSError *)error { NSDictionary *jsError = [self getJSError:error]; @@ -1737,19 +1728,25 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user { - (NSArray *)convertMultiFactorData:(NSArray *)hints { NSMutableArray *enrolledFactors = [NSMutableArray array]; - for (FIRPhoneMultiFactorInfo *hint in hints) { + for (FIRMultiFactorInfo *hint in hints) { NSString *enrollmentTime = [[[NSISO8601DateFormatter alloc] init] stringFromDate:hint.enrollmentDate]; - [enrolledFactors addObject:@{ + + NSMutableDictionary *factorDict = [@{ @"uid" : hint.UID, - @"factorId" : [self getJSFactorId:(hint.factorID)], + @"factorId" : hint.factorID, @"displayName" : hint.displayName == nil ? [NSNull null] : hint.displayName, @"enrollmentTime" : enrollmentTime, // @deprecated enrollmentDate kept for backwards compatibility, please use enrollmentTime @"enrollmentDate" : enrollmentTime, - // phoneNumber only present on FIRPhoneMultiFactorInfo - @"phoneNumber" : hint.phoneNumber == nil ? [NSNull null] : hint.phoneNumber, - }]; + } mutableCopy]; + + // only support phone mutli factor + if ([hint isKindOfClass:[FIRPhoneMultiFactorInfo class]]) { + FIRPhoneMultiFactorInfo *phoneHint = (FIRPhoneMultiFactorInfo *)hint; + factorDict[@"phoneNumber"] = phoneHint.phoneNumber; + [enrolledFactors addObject:factorDict]; + } } return enrolledFactors; }