Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tvOS support #8111

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions packages/auth/ios/RNFBAuth/RNFBAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
static __strong NSMutableDictionary *emulatorConfigs;
// Used for caching credentials between method calls.
static __strong NSMutableDictionary<NSString *, FIRAuthCredential *> *credentials;
#if !TARGET_OS_TV
#if TARGET_OS_IOS
Copy link
Collaborator Author

@mikehardy mikehardy Nov 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static __strong NSMutableDictionary<NSString *, FIRMultiFactorResolver *> *cachedResolver;
static __strong NSMutableDictionary<NSString *, FIRMultiFactorSession *> *cachedSessions;
#endif
Expand All @@ -78,7 +78,7 @@ - (id)init {
idTokenHandlers = [[NSMutableDictionary alloc] init];
emulatorConfigs = [[NSMutableDictionary alloc] init];
credentials = [[NSMutableDictionary alloc] init];
#if !TARGET_OS_TV
#if TARGET_OS_IOS
cachedResolver = [[NSMutableDictionary alloc] init];
cachedSessions = [[NSMutableDictionary alloc] init];
#endif
Expand Down Expand Up @@ -107,7 +107,7 @@ - (void)invalidate {
[idTokenHandlers removeAllObjects];

[credentials removeAllObjects];
#if !TARGET_OS_TV
#if TARGET_OS_IOS
[cachedResolver removeAllObjects];
[cachedSessions removeAllObjects];
#endif
Expand Down Expand Up @@ -421,7 +421,7 @@ - (void)invalidate {
}
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
RCT_EXPORT_METHOD(updatePhoneNumber
: (FIRApp *)firebaseApp
: (NSString *)provider
Expand Down Expand Up @@ -625,7 +625,7 @@ - (void)invalidate {
[builder setCustomParameters:provider[@"customParameters"]];
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
[builder getCredentialWithUIDelegate:nil
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
Expand Down Expand Up @@ -827,7 +827,7 @@ - (void)invalidate {
}];
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
RCT_EXPORT_METHOD(signInWithPhoneNumber
: (FIRApp *)firebaseApp
: (NSString *)phoneNumber
Expand Down Expand Up @@ -1134,7 +1134,7 @@ - (void)invalidate {
[builder setCustomParameters:provider[@"parameters"]];
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
[builder getCredentialWithUIDelegate:nil
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
Expand Down Expand Up @@ -1262,7 +1262,7 @@ - (void)invalidate {
if (provider[@"parameters"]) {
[builder setCustomParameters:provider[@"parameters"]];
}
#if !TARGET_OS_TV
#if TARGET_OS_IOS
[builder getCredentialWithUIDelegate:nil
completion:^(FIRAuthCredential *_Nullable credential,
NSError *_Nullable error) {
Expand Down Expand Up @@ -1390,7 +1390,7 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider
} else if ([provider compare:@"github.com" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
credential = [FIRGitHubAuthProvider credentialWithToken:authToken];
} else if ([provider compare:@"phone" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
#if !TARGET_OS_TV
#if TARGET_OS_IOS
DLog(@"using app credGen: %@", firebaseApp.name) credential =
[[FIRPhoneAuthProvider providerWithAuth:[FIRAuth authWithApp:firebaseApp]]
credentialWithVerificationID:authToken
Expand Down Expand Up @@ -1440,7 +1440,7 @@ - (void)promiseNoUser:(RCTPromiseResolveBlock)resolve
}
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
- (NSDictionary *)multiFactorResolverToDict:(FIRMultiFactorResolver *)resolver {
// Temporarily store the non-serializable session for later
NSString *sessionHash = [NSString stringWithFormat:@"%@", @([resolver.session hash])];
Expand Down Expand Up @@ -1563,7 +1563,7 @@ - (NSDictionary *)getJSError:(NSError *)error {


NSDictionary *resolverDict = nil;
#if !TARGET_OS_TV
#if TARGET_OS_IOS
if ([error userInfo][FIRAuthErrorUserInfoMultiFactorResolverKey] != nil) {
FIRMultiFactorResolver *resolver = error.userInfo[FIRAuthErrorUserInfoMultiFactorResolverKey];
resolverDict = [self multiFactorResolverToDict:resolver];
Expand Down Expand Up @@ -1718,14 +1718,14 @@ - (NSDictionary *)firebaseUserToDict:(FIRUser *)user {
@"refreshToken" : user.refreshToken,
@"tenantId" : user.tenantID ? (id)user.tenantID : [NSNull null],
keyUid : user.uid,
#if !TARGET_OS_TV
#if TARGET_OS_IOS
@"multiFactor" :
@{@"enrolledFactors" : [self convertMultiFactorData:user.multiFactor.enrolledFactors]}
#endif
};
}

#if !TARGET_OS_TV
#if TARGET_OS_IOS
- (NSArray<NSMutableDictionary *> *)convertMultiFactorData:(NSArray<FIRMultiFactorInfo *> *)hints {
NSMutableArray *enrolledFactors = [NSMutableArray array];

Expand Down