@@ -307,9 +307,8 @@ - (void)invalidate {
307307 : (RCTPromiseResolveBlock)resolve
308308 : (RCTPromiseRejectBlock)reject) {
309309 FIRUser *user = [FIRAuth authWithApp: firebaseApp].currentUser ;
310-
311310 if (user) {
312- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
311+ [self reloadAndReturnUser: user resolver: resolve rejecter: reject firebaseApp: firebaseApp ];
313312 } else {
314313 [self promiseNoUser: resolve rejecter: reject isError: YES ];
315314 }
@@ -383,7 +382,10 @@ - (void)invalidate {
383382 if (error) {
384383 [self promiseRejectAuthException: reject error: error];
385384 } else {
386- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
385+ [self reloadAndReturnUser: user
386+ resolver: resolve
387+ rejecter: reject
388+ firebaseApp: firebaseApp];
387389 }
388390 }];
389391 } else {
@@ -426,7 +428,8 @@ - (void)invalidate {
426428 FIRPhoneAuthCredential *credential =
427429 (FIRPhoneAuthCredential *)[self getCredentialForProvider: provider
428430 token: authToken
429- secret: authSecret];
431+ secret: authSecret
432+ firebaseApp: firebaseApp];
430433
431434 if (credential == nil ) {
432435 [RNFBSharedUtils
@@ -481,7 +484,7 @@ - (void)invalidate {
481484 if (error) {
482485 [self promiseRejectAuthException: reject error: error];
483486 } else {
484- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
487+ [self reloadAndReturnUser: user resolver: resolve rejecter: reject firebaseApp: firebaseApp ];
485488 }
486489 }];
487490 } else {
@@ -565,8 +568,8 @@ - (void)invalidate {
565568 : (RCTPromiseRejectBlock)reject) {
566569 FIRAuthCredential *credential = [self getCredentialForProvider: provider
567570 token: authToken
568- secret: authSecret];
569-
571+ secret: authSecret
572+ firebaseApp: firebaseApp];
570573 if (credential == nil ) {
571574 [RNFBSharedUtils rejectPromiseWithUserInfo: reject
572575 userInfo: (NSMutableDictionary *)@{
@@ -575,8 +578,7 @@ - (void)invalidate {
575578 @" has expired or is not currently supported." ,
576579 }];
577580 }
578-
579- [[FIRAuth authWithApp: firebaseApp]
581+ DLog (@" using app SignInWithCredential: %@ " , firebaseApp.name )[[FIRAuth authWithApp: firebaseApp]
580582 signInWithCredential: credential
581583 completion: ^(FIRAuthDataResult *authResult, NSError *error) {
582584 if (error) {
@@ -602,7 +604,8 @@ - (void)invalidate {
602604 }];
603605 }
604606
605- __block FIROAuthProvider *builder = [FIROAuthProvider providerWithProviderID: providerId];
607+ __block FIROAuthProvider *builder =
608+ [FIROAuthProvider providerWithProviderID: providerId auth: [FIRAuth authWithApp: firebaseApp]];
606609 // Add scopes if present
607610 if (provider[@" scopes" ]) {
608611 [builder setScopes: provider[@" scopes" ]];
@@ -620,7 +623,7 @@ - (void)invalidate {
620623 return ;
621624 }
622625 if (credential) {
623- [[FIRAuth auth ]
626+ [[FIRAuth authWithApp: firebaseApp ]
624627 signInWithCredential: credential
625628 completion: ^(FIRAuthDataResult *_Nullable authResult,
626629 NSError *_Nullable error) {
@@ -817,7 +820,8 @@ - (void)invalidate {
817820 : (NSString *)phoneNumber
818821 : (RCTPromiseResolveBlock)resolve
819822 : (RCTPromiseRejectBlock)reject) {
820- [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
823+ DLog (@" SignInWthPhoneNumber instance: %@ " ,
824+ firebaseApp.name )[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
821825 verifyPhoneNumber: phoneNumber
822826 UIDelegate: nil
823827 completion: ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
@@ -858,8 +862,8 @@ - (void)invalidate {
858862 }];
859863 return ;
860864 }
861-
862- [ FIRPhoneAuthProvider.provider
865+ DLog ( @" using instance verifyPhoneNumberWithMultiFactorInfo: %@ " ,
866+ firebaseApp. name )[[ FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
863867 verifyPhoneNumberWithMultiFactorInfo: hint
864868 UIDelegate: nil
865869 multiFactorSession: session
@@ -868,7 +872,8 @@ - (void)invalidate {
868872 if (error) {
869873 [self promiseRejectAuthException: reject error: error];
870874 } else {
871- resolve (verificationID);
875+ DLog (@" verificationID: %@ " , verificationID)
876+ resolve (verificationID);
872877 }
873878 }];
874879}
@@ -880,7 +885,8 @@ - (void)invalidate {
880885 : (RCTPromiseResolveBlock)resolve
881886 : (RCTPromiseRejectBlock)reject) {
882887 FIRMultiFactorSession *session = cachedSessions[sessionId];
883- [FIRPhoneAuthProvider.provider
888+ DLog (@" using instance VerifyPhoneNumberForMultifactor: %@ " ,
889+ firebaseApp.name )[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
884890 verifyPhoneNumber: phoneNumber
885891 UIDelegate: nil
886892 multiFactorSession: session
@@ -901,19 +907,22 @@ - (void)invalidate {
901907 : (NSString *)verificationCode
902908 : (RCTPromiseResolveBlock)resolve
903909 : (RCTPromiseRejectBlock)reject) {
904- FIRPhoneAuthCredential *credential =
905- [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
906- credentialWithVerificationID: verificationId
907- verificationCode: verificationCode];
908- FIRMultiFactorAssertion *assertion =
910+ DLog (@" using instance resolve MultiFactorSignIn: %@ " , firebaseApp.name )
911+ FIRPhoneAuthCredential *credential =
912+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
913+ credentialWithVerificationID: verificationId
914+ verificationCode: verificationCode];
915+ DLog (@" credential: %@ " , credential) FIRMultiFactorAssertion *assertion =
909916 [FIRPhoneMultiFactorGenerator assertionWithCredential: credential];
917+
910918 [cachedResolver[sessionKey] resolveSignInWithAssertion: assertion
911919 completion: ^(FIRAuthDataResult *_Nullable authResult,
912920 NSError *_Nullable error) {
913- if (error) {
921+ DLog ( @" authError: %@ " , error) if (error) {
914922 [self promiseRejectAuthException: reject
915923 error: error];
916- } else {
924+ }
925+ else {
917926 [self promiseWithAuthResult: resolve
918927 rejecter: reject
919928 authResult: authResult];
@@ -946,9 +955,11 @@ - (void)invalidate {
946955 : (NSString *_Nullable)displayName
947956 : (RCTPromiseResolveBlock)resolve
948957 : (RCTPromiseRejectBlock)reject) {
949- FIRPhoneAuthCredential *credential =
950- [FIRPhoneAuthProvider.provider credentialWithVerificationID: verificationId
951- verificationCode: verificationCode];
958+ DLog (@" using instance finalizeMultifactorEnrollment: %@ " , firebaseApp.name )
959+ FIRPhoneAuthCredential *credential =
960+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
961+ credentialWithVerificationID: verificationId
962+ verificationCode: verificationCode];
952963 FIRMultiFactorAssertion *assertion =
953964 [FIRPhoneMultiFactorGenerator assertionWithCredential: credential];
954965 FIRUser *user = [FIRAuth authWithApp: firebaseApp].currentUser ;
@@ -969,12 +980,13 @@ - (void)invalidate {
969980 : (FIRApp *)firebaseApp
970981 : (NSString *)phoneNumber
971982 : (NSString *)requestKey) {
972- [FIRPhoneAuthProvider.provider
983+ DLog (@" using instance verifyPhoneNumber: %@ " ,
984+ firebaseApp.name )[[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
973985 verifyPhoneNumber: phoneNumber
974986 UIDelegate: nil
975987 completion: ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
976988 if (error) {
977- NSDictionary *jsError = [self getJSError: ( error) ];
989+ NSDictionary *jsError = [self getJSError: error];
978990 NSDictionary *body = @{
979991 @" type" : @" onVerificationFailed" ,
980992 @" requestKey" : requestKey,
@@ -1007,12 +1019,14 @@ - (void)invalidate {
10071019 NSString *verificationId = [defaults stringForKey: @" authVerificationID" ];
10081020
10091021 FIRAuthCredential *credential =
1010- [[FIRPhoneAuthProvider provider ] credentialWithVerificationID: verificationId
1011- verificationCode: verificationCode];
1022+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
1023+ credentialWithVerificationID: verificationId
1024+ verificationCode: verificationCode];
10121025
10131026 [[FIRAuth authWithApp: firebaseApp]
10141027 signInWithCredential: credential
10151028 completion: ^(FIRAuthDataResult *authResult, NSError *error) {
1029+ DLog (@" auth error: %lo ng" , (long )error.code );
10161030 if (error) {
10171031 [self promiseRejectAuthException: reject error: error];
10181032 } else {
@@ -1030,7 +1044,8 @@ - (void)invalidate {
10301044 : (RCTPromiseRejectBlock)reject) {
10311045 FIRAuthCredential *credential = [self getCredentialForProvider: provider
10321046 token: authToken
1033- secret: authSecret];
1047+ secret: authSecret
1048+ firebaseApp: firebaseApp];
10341049
10351050 if (credential == nil ) {
10361051 [RNFBSharedUtils rejectPromiseWithUserInfo: reject
@@ -1077,7 +1092,8 @@ - (void)invalidate {
10771092 return ;
10781093 }
10791094
1080- __block FIROAuthProvider *builder = [FIROAuthProvider providerWithProviderID: providerId];
1095+ __block FIROAuthProvider *builder =
1096+ [FIROAuthProvider providerWithProviderID: providerId auth: [FIRAuth authWithApp: firebaseApp]];
10811097 // Add scopes if present
10821098 if (provider[@" scopes" ]) {
10831099 [builder setScopes: provider[@" scopes" ]];
@@ -1131,7 +1147,10 @@ - (void)invalidate {
11311147 if (error) {
11321148 [self promiseRejectAuthException: reject error: error];
11331149 } else {
1134- [self reloadAndReturnUser: user resolver: resolve rejecter: reject];
1150+ [self reloadAndReturnUser: user
1151+ resolver: resolve
1152+ rejecter: reject
1153+ firebaseApp: firebaseApp];
11351154 }
11361155 }];
11371156 } else {
@@ -1148,7 +1167,8 @@ - (void)invalidate {
11481167 : (RCTPromiseRejectBlock)reject) {
11491168 FIRAuthCredential *credential = [self getCredentialForProvider: provider
11501169 token: authToken
1151- secret: authSecret];
1170+ secret: authSecret
1171+ firebaseApp: firebaseApp];
11521172
11531173 if (credential == nil ) {
11541174 [RNFBSharedUtils rejectPromiseWithUserInfo: reject
@@ -1199,7 +1219,8 @@ - (void)invalidate {
11991219 return ;
12001220 }
12011221
1202- __block FIROAuthProvider *builder = [FIROAuthProvider providerWithProviderID: providerId];
1222+ __block FIROAuthProvider *builder =
1223+ [FIROAuthProvider providerWithProviderID: providerId auth: [FIRAuth authWithApp: firebaseApp]];
12031224 // Add scopes if present
12041225 if (provider[@" scopes" ]) {
12051226 [builder setScopes: provider[@" scopes" ]];
@@ -1305,7 +1326,8 @@ - (void)invalidate {
13051326
13061327- (FIRAuthCredential *)getCredentialForProvider : (NSString *)provider
13071328 token : (NSString *)authToken
1308- secret : (NSString *)authTokenSecret {
1329+ secret : (NSString *)authTokenSecret
1330+ firebaseApp : (FIRApp *)firebaseApp {
13091331 FIRAuthCredential *credential;
13101332
13111333 // First check if we cached an authToken
@@ -1334,8 +1356,10 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
13341356 } else if ([provider compare: @" github.com" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
13351357 credential = [FIRGitHubAuthProvider credentialWithToken: authToken];
13361358 } else if ([provider compare: @" phone" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
1337- credential = [[FIRPhoneAuthProvider provider ] credentialWithVerificationID: authToken
1338- verificationCode: authTokenSecret];
1359+ DLog (@" using app credGen: %@ " , firebaseApp.name ) credential =
1360+ [[FIRPhoneAuthProvider providerWithAuth: [FIRAuth authWithApp: firebaseApp]]
1361+ credentialWithVerificationID: authToken
1362+ verificationCode: authTokenSecret];
13391363 } else if ([provider compare: @" oauth" options: NSCaseInsensitiveSearch] == NSOrderedSame) {
13401364 credential = [FIROAuthProvider credentialWithProviderID: @" oauth"
13411365 IDToken: authToken
@@ -1355,7 +1379,8 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
13551379// correctly refresh the user object when performing certain operations
13561380- (void )reloadAndReturnUser : (FIRUser *)user
13571381 resolver : (RCTPromiseResolveBlock)resolve
1358- rejecter : (RCTPromiseRejectBlock)reject {
1382+ rejecter : (RCTPromiseRejectBlock)reject
1383+ firebaseApp : (FIRApp *)firebaseApp {
13591384 [user reloadWithCompletion: ^(NSError *_Nullable error) {
13601385 if (error) {
13611386 [self promiseRejectAuthException: reject error: error];
@@ -1386,6 +1411,7 @@ - (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
13861411 return @{
13871412 @" hints" : [self convertMultiFactorData: resolver.hints],
13881413 @" session" : sessionHash,
1414+ @" auth" : resolver.auth
13891415 };
13901416}
13911417
@@ -1399,7 +1425,7 @@ - (NSString *)getJSFactorId:(NSString *)factorId {
13991425}
14001426
14011427- (void )promiseRejectAuthException : (RCTPromiseRejectBlock)reject error : (NSError *)error {
1402- NSDictionary *jsError = [self getJSError: ( error) ];
1428+ NSDictionary *jsError = [self getJSError: error];
14031429
14041430 [RNFBSharedUtils
14051431 rejectPromiseWithUserInfo: reject
@@ -1499,8 +1525,7 @@ - (NSDictionary *)getJSError:(NSError *)error {
14991525
15001526 NSDictionary *resolverDict = nil ;
15011527 if ([error userInfo ][FIRAuthErrorUserInfoMultiFactorResolverKey] != nil ) {
1502- FIRMultiFactorResolver *resolver =
1503- (FIRMultiFactorResolver *)error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
1528+ FIRMultiFactorResolver *resolver = error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
15041529 resolverDict = [self multiFactorResolverToDict: resolver];
15051530
15061531 NSString *sessionKey = [NSString stringWithFormat: @" %@ " , @([resolver.session hash ])];
@@ -1665,7 +1690,7 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
16651690 [[[NSISO8601DateFormatter alloc ] init ] stringFromDate: hint.enrollmentDate];
16661691 [enrolledFactors addObject: @{
16671692 @" uid" : hint.UID ,
1668- @" factorId" : hint. factorID == nil ? [ NSNull null ] : [self getJSFactorId: (hint.factorID)],
1693+ @" factorId" : [self getJSFactorId: (hint.factorID)],
16691694 @" displayName" : hint.displayName == nil ? [NSNull null ] : hint.displayName ,
16701695 @" enrollmentDate" : enrollmentDate,
16711696 }];
@@ -1720,4 +1745,4 @@ - (FIRActionCodeSettings *)buildActionCodeSettings:(NSDictionary *)actionCodeSet
17201745 return settings;
17211746}
17221747
1723- @end
1748+ @end
0 commit comments