@@ -101,7 +101,6 @@ @interface FLTFirebaseAuthPlugin ()
101
101
@end
102
102
103
103
@implementation FLTFirebaseAuthPlugin {
104
- #if TARGET_OS_IPHONE
105
104
// Map an id to a MultiFactorSession object.
106
105
NSMutableDictionary <NSString *, FIRMultiFactorSession *> *_multiFactorSessionMap;
107
106
@@ -114,8 +113,6 @@ @implementation FLTFirebaseAuthPlugin {
114
113
// Map an id to a MultiFactorResolver object.
115
114
NSMutableDictionary <NSString *, FIRTOTPSecret *> *_multiFactorTotpSecretMap;
116
115
117
- #endif
118
-
119
116
NSObject <FlutterBinaryMessenger> *_binaryMessenger;
120
117
NSMutableDictionary <NSString *, FlutterEventChannel *> *_eventChannels;
121
118
NSMutableDictionary <NSString *, NSObject <FlutterStreamHandler> *> *_streamHandlers;
@@ -133,13 +130,10 @@ - (instancetype)init:(NSObject<FlutterBinaryMessenger> *)messenger {
133
130
_eventChannels = [NSMutableDictionary dictionary ];
134
131
_streamHandlers = [NSMutableDictionary dictionary ];
135
132
136
- #if TARGET_OS_IPHONE
137
133
_multiFactorSessionMap = [NSMutableDictionary dictionary ];
138
134
_multiFactorResolverMap = [NSMutableDictionary dictionary ];
139
135
_multiFactorAssertionMap = [NSMutableDictionary dictionary ];
140
136
_multiFactorTotpSecretMap = [NSMutableDictionary dictionary ];
141
-
142
- #endif
143
137
}
144
138
return self;
145
139
}
@@ -156,13 +150,10 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
156
150
[registrar addApplicationDelegate: instance];
157
151
SetUpFirebaseAuthHostApi (registrar.messenger , instance);
158
152
SetUpFirebaseAuthUserHostApi (registrar.messenger , instance);
159
-
160
- #if TARGET_OS_IPHONE
161
153
SetUpMultiFactorUserHostApi (registrar.messenger , instance);
162
154
SetUpMultiFactoResolverHostApi (registrar.messenger , instance);
163
155
SetUpMultiFactorTotpHostApi (registrar.messenger , instance);
164
156
SetUpMultiFactorTotpSecretHostApi (registrar.messenger , instance);
165
- #endif
166
157
}
167
158
168
159
+ (FlutterError *)convertToFlutterError : (NSError *)error {
@@ -509,11 +500,6 @@ - (void)handleMultiFactorError:(AuthPigeonFirebaseApp *)app
509
500
completion : (nonnull void (^)(PigeonUserCredential *_Nullable,
510
501
FlutterError *_Nullable))completion
511
502
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
517
503
FIRMultiFactorResolver *resolver =
518
504
(FIRMultiFactorResolver *)error.userInfo [FIRAuthErrorUserInfoMultiFactorResolverKey];
519
505
@@ -554,7 +540,6 @@ - (void)handleMultiFactorError:(AuthPigeonFirebaseApp *)app
554
540
completion (nil , [FlutterError errorWithCode: @" second-factor-required"
555
541
message: error.description
556
542
details: output]);
557
- #endif
558
543
}
559
544
560
545
static void launchAppleSignInRequest (FLTFirebaseAuthPlugin *object, AuthPigeonFirebaseApp *app,
@@ -835,13 +820,11 @@ - (void)ensureAPNSTokenSetting {
835
820
#endif
836
821
}
837
822
838
- #if !TARGET_OS_OSX
839
823
- (FIRMultiFactor *)getAppMultiFactorFromPigeon : (nonnull AuthPigeonFirebaseApp *)app {
840
824
FIRAuth *auth = [self getFIRAuthFromAppNameFromPigeon: app];
841
825
FIRUser *currentUser = auth.currentUser ;
842
826
return currentUser.multiFactor ;
843
827
}
844
- #endif
845
828
846
829
- (nonnull ASPresentationAnchor)presentationAnchorForAuthorizationController :
847
830
(nonnull ASAuthorizationController *)controller API_AVAILABLE(macos(10.15 ), ios(13.0 )) {
@@ -852,12 +835,16 @@ - (nonnull ASPresentationAnchor)presentationAnchorForAuthorizationController:
852
835
#endif
853
836
}
854
837
855
- #if TARGET_OS_IPHONE
856
-
857
838
- (void )enrollPhoneApp : (nonnull AuthPigeonFirebaseApp *)app
858
839
assertion : (nonnull PigeonPhoneMultiFactorAssertion *)assertion
859
840
displayName : (nullable NSString *)displayName
860
841
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
+
861
848
FIRMultiFactor *multiFactor = [self getAppMultiFactorFromPigeon: app];
862
849
863
850
FIRPhoneAuthCredential *credential =
@@ -879,6 +866,7 @@ - (void)enrollPhoneApp:(nonnull AuthPigeonFirebaseApp *)app
879
866
details: nil ]);
880
867
}
881
868
}];
869
+ #endif
882
870
}
883
871
884
872
- (void )getEnrolledFactorsApp : (nonnull AuthPigeonFirebaseApp *)app
@@ -969,10 +957,12 @@ - (void)resolveSignInResolverId:(nonnull NSString *)resolverId
969
957
FIRMultiFactorAssertion *multiFactorAssertion;
970
958
971
959
if (assertion != nil ) {
960
+ #if TARGET_OS_IPHONE
972
961
FIRPhoneAuthCredential *credential =
973
962
[[FIRPhoneAuthProvider provider ] credentialWithVerificationID: [assertion verificationId ]
974
963
verificationCode: [assertion verificationCode ]];
975
964
multiFactorAssertion = [FIRPhoneMultiFactorGenerator assertionWithCredential: credential];
965
+ #endif
976
966
} else if (totpAssertionId != nil ) {
977
967
multiFactorAssertion = _multiFactorAssertionMap[totpAssertionId];
978
968
} else {
@@ -1065,8 +1055,6 @@ - (void)openInOtpAppSecretKey:(nonnull NSString *)secretKey
1065
1055
completion (nil );
1066
1056
}
1067
1057
1068
- #endif
1069
-
1070
1058
- (void )applyActionCodeApp : (nonnull AuthPigeonFirebaseApp *)app
1071
1059
code : (nonnull NSString *)code
1072
1060
completion : (nonnull void (^)(FlutterError *_Nullable))completion {
0 commit comments