Skip to content

Commit 9fc2ab3

Browse files
committed
gracefully handle unsupported phone auth methods
1 parent d69b4a1 commit 9fc2ab3

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/FLTFirebaseAuthPlugin.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -850,12 +850,16 @@ - (nonnull ASPresentationAnchor)presentationAnchorForAuthorizationController:
850850
#endif
851851
}
852852

853-
#if TARGET_OS_IPHONE
854-
855853
- (void)enrollPhoneApp:(nonnull AuthPigeonFirebaseApp *)app
856854
assertion:(nonnull PigeonPhoneMultiFactorAssertion *)assertion
857855
displayName:(nullable NSString *)displayName
858856
completion:(nonnull void (^)(FlutterError *_Nullable))completion {
857+
#if TARGET_OS_OSX
858+
completion([FlutterError errorWithCode:@"unsupported-platform"
859+
message:@"Phone authentication is not supported on macOS"
860+
details:nil]);
861+
#else
862+
859863
FIRMultiFactor *multiFactor = [self getAppMultiFactorFromPigeon:app];
860864

861865
FIRPhoneAuthCredential *credential =
@@ -877,9 +881,8 @@ - (void)enrollPhoneApp:(nonnull AuthPigeonFirebaseApp *)app
877881
details:nil]);
878882
}
879883
}];
880-
}
881-
882884
#endif
885+
}
883886

884887
- (void)getEnrolledFactorsApp:(nonnull AuthPigeonFirebaseApp *)app
885888
completion:(nonnull void (^)(NSArray<PigeonMultiFactorInfo *> *_Nullable,
@@ -959,13 +962,16 @@ - (void)enrollTotpApp:(nonnull AuthPigeonFirebaseApp *)app
959962
}];
960963
}
961964

962-
#if TARGET_OS_IPHONE
963-
964965
- (void)resolveSignInResolverId:(nonnull NSString *)resolverId
965966
assertion:(nullable PigeonPhoneMultiFactorAssertion *)assertion
966967
totpAssertionId:(nullable NSString *)totpAssertionId
967968
completion:(nonnull void (^)(PigeonUserCredential *_Nullable,
968969
FlutterError *_Nullable))completion {
970+
#if TARGET_OS_OSX
971+
completion(nil, [FlutterError errorWithCode:@"unsupported-platform"
972+
message:@"Phone authentication is not supported on macOS"
973+
details:nil]);
974+
#else
969975
FIRMultiFactorResolver *resolver = _multiFactorResolverMap[resolverId];
970976

971977
FIRMultiFactorAssertion *multiFactorAssertion;
@@ -999,9 +1005,8 @@ - (void)resolveSignInResolverId:(nonnull NSString *)resolverId
9991005
details:nil]);
10001006
}
10011007
}];
1002-
}
1003-
10041008
#endif
1009+
}
10051010

10061011
- (void)generateSecretSessionId:(nonnull NSString *)sessionId
10071012
completion:(nonnull void (^)(PigeonTotpSecret *_Nullable,

0 commit comments

Comments
 (0)