@@ -101,7 +101,6 @@ @interface FLTFirebaseAuthPlugin ()
101101@end
102102
103103@implementation FLTFirebaseAuthPlugin {
104- #if TARGET_OS_IPHONE
105104 // Map an id to a MultiFactorSession object.
106105 NSMutableDictionary <NSString *, FIRMultiFactorSession *> *_multiFactorSessionMap;
107106
@@ -114,8 +113,6 @@ @implementation FLTFirebaseAuthPlugin {
114113 // Map an id to a MultiFactorResolver object.
115114 NSMutableDictionary <NSString *, FIRTOTPSecret *> *_multiFactorTotpSecretMap;
116115
117- #endif
118-
119116 NSObject <FlutterBinaryMessenger> *_binaryMessenger;
120117 NSMutableDictionary <NSString *, FlutterEventChannel *> *_eventChannels;
121118 NSMutableDictionary <NSString *, NSObject <FlutterStreamHandler> *> *_streamHandlers;
@@ -133,13 +130,10 @@ - (instancetype)init:(NSObject<FlutterBinaryMessenger> *)messenger {
133130 _eventChannels = [NSMutableDictionary dictionary ];
134131 _streamHandlers = [NSMutableDictionary dictionary ];
135132
136- #if TARGET_OS_IPHONE
137133 _multiFactorSessionMap = [NSMutableDictionary dictionary ];
138134 _multiFactorResolverMap = [NSMutableDictionary dictionary ];
139135 _multiFactorAssertionMap = [NSMutableDictionary dictionary ];
140136 _multiFactorTotpSecretMap = [NSMutableDictionary dictionary ];
141-
142- #endif
143137 }
144138 return self;
145139}
@@ -156,13 +150,10 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
156150 [registrar addApplicationDelegate: instance];
157151 SetUpFirebaseAuthHostApi (registrar.messenger , instance);
158152 SetUpFirebaseAuthUserHostApi (registrar.messenger , instance);
159-
160- #if TARGET_OS_IPHONE
161153 SetUpMultiFactorUserHostApi (registrar.messenger , instance);
162154 SetUpMultiFactoResolverHostApi (registrar.messenger , instance);
163155 SetUpMultiFactorTotpHostApi (registrar.messenger , instance);
164156 SetUpMultiFactorTotpSecretHostApi (registrar.messenger , instance);
165- #endif
166157}
167158
168159+ (FlutterError *)convertToFlutterError : (NSError *)error {
@@ -509,11 +500,6 @@ - (void)handleMultiFactorError:(AuthPigeonFirebaseApp *)app
509500 completion : (nonnull void (^)(PigeonUserCredential *_Nullable,
510501 FlutterError *_Nullable))completion
511502 withError:(NSError *_Nullable)error {
512- #if TARGET_OS_OSX
513- completion (nil , [FlutterError errorWithCode: @" second-factor-required"
514- message: error.description
515- details: nil ]);
516- #else
517503 FIRMultiFactorResolver *resolver =
518504 (FIRMultiFactorResolver *)error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
519505
@@ -554,7 +540,6 @@ - (void)handleMultiFactorError:(AuthPigeonFirebaseApp *)app
554540 completion (nil , [FlutterError errorWithCode: @" second-factor-required"
555541 message: error.description
556542 details: output]);
557- #endif
558543}
559544
560545static void launchAppleSignInRequest (FLTFirebaseAuthPlugin *object, AuthPigeonFirebaseApp *app,
@@ -835,13 +820,11 @@ - (void)ensureAPNSTokenSetting {
835820#endif
836821}
837822
838- #if !TARGET_OS_OSX
839823- (FIRMultiFactor *)getAppMultiFactorFromPigeon : (nonnull AuthPigeonFirebaseApp *)app {
840824 FIRAuth *auth = [self getFIRAuthFromAppNameFromPigeon: app];
841825 FIRUser *currentUser = auth.currentUser ;
842826 return currentUser.multiFactor ;
843827}
844- #endif
845828
846829- (nonnull ASPresentationAnchor)presentationAnchorForAuthorizationController :
847830 (nonnull ASAuthorizationController *)controller API_AVAILABLE(macos(10.15 ), ios(13.0 )) {
@@ -852,12 +835,16 @@ - (nonnull ASPresentationAnchor)presentationAnchorForAuthorizationController:
852835#endif
853836}
854837
855- #if TARGET_OS_IPHONE
856-
857838- (void )enrollPhoneApp : (nonnull AuthPigeonFirebaseApp *)app
858839 assertion : (nonnull PigeonPhoneMultiFactorAssertion *)assertion
859840 displayName : (nullable NSString *)displayName
860841 completion : (nonnull void (^)(FlutterError *_Nullable))completion {
842+ #if TARGET_OS_OSX
843+ completion ([FlutterError errorWithCode: @" unsupported-platform"
844+ message: @" Phone authentication is not supported on macOS"
845+ details: nil ]);
846+ #else
847+
861848 FIRMultiFactor *multiFactor = [self getAppMultiFactorFromPigeon: app];
862849
863850 FIRPhoneAuthCredential *credential =
@@ -879,6 +866,7 @@ - (void)enrollPhoneApp:(nonnull AuthPigeonFirebaseApp *)app
879866 details: nil ]);
880867 }
881868 }];
869+ #endif
882870}
883871
884872- (void )getEnrolledFactorsApp : (nonnull AuthPigeonFirebaseApp *)app
@@ -969,10 +957,12 @@ - (void)resolveSignInResolverId:(nonnull NSString *)resolverId
969957 FIRMultiFactorAssertion *multiFactorAssertion;
970958
971959 if (assertion != nil ) {
960+ #if TARGET_OS_IPHONE
972961 FIRPhoneAuthCredential *credential =
973962 [[FIRPhoneAuthProvider provider ] credentialWithVerificationID: [assertion verificationId ]
974963 verificationCode: [assertion verificationCode ]];
975964 multiFactorAssertion = [FIRPhoneMultiFactorGenerator assertionWithCredential: credential];
965+ #endif
976966 } else if (totpAssertionId != nil ) {
977967 multiFactorAssertion = _multiFactorAssertionMap[totpAssertionId];
978968 } else {
@@ -1065,8 +1055,6 @@ - (void)openInOtpAppSecretKey:(nonnull NSString *)secretKey
10651055 completion (nil );
10661056}
10671057
1068- #endif
1069-
10701058- (void )applyActionCodeApp : (nonnull AuthPigeonFirebaseApp *)app
10711059 code : (nonnull NSString *)code
10721060 completion : (nonnull void (^)(FlutterError *_Nullable))completion {
0 commit comments