Skip to content

Commit

Permalink
style(lint, ios): fix flagged issues from Xcode
Browse files Browse the repository at this point in the history
mostly nullability and deprecation items
  • Loading branch information
mikehardy committed Nov 7, 2024
1 parent 395d592 commit fab5071
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
@interface RNAppleAuthASAuthorizationDelegates : NSObject <ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding>

@property(nonatomic, strong, nullable) NSString *nonce;
@property(nonatomic, strong, nullable) void (^completion)(NSError *, NSDictionary *);
@property(nonatomic, strong, nullable) void (^completion)(NSError *_Nullable, NSDictionary *_Nullable);

- (instancetype)initWithCompletion:(void (^)(NSError *error, NSDictionary *authorizationCredential))completion andNonce:(NSString *)nonce;
- (instancetype _Nullable )initWithCompletion:(void (^_Nonnull)(NSError * _Nullable error, NSDictionary * _Nullable authorizationCredential))completion andNonce:(NSString *_Nullable)nonce;

- (void)performRequestsForAuthorizationController:(ASAuthorizationController *)authorizationController;
- (void)performRequestsForAuthorizationController:(ASAuthorizationController *_Nonnull)authorizationController;

@end

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@implementation RNAppleAuthASAuthorizationDelegates

- (instancetype)initWithCompletion:(void (^)(NSError *error, NSDictionary *authorizationCredential))completion andNonce:(NSString *)nonce {
- (instancetype)initWithCompletion:(nonnull void (^)(NSError *error, NSDictionary *authorizationCredential))completion andNonce:(NSString *)nonce {
if (self = [super init]) {
_completion = completion;
_nonce = nonce;
Expand All @@ -54,6 +54,9 @@ - (ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthoriz
}
return window;
#else
// I believe the vision OS one above is actually the best way to handle the deprecation:
// Apple Auth not supported until iOS13 anyway, so the solution above should be using avaliable APIs (13+)
// iPadOS optimal solution also relies on using activation state vs just using last connected Scene
return [[UIApplication sharedApplication] keyWindow];
#endif
#endif
Expand All @@ -70,7 +73,7 @@ - (void)authorizationController:(ASAuthorizationController *)controller didCompl

- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error {
NSLog(@"RNAppleAuth -> didCompleteWithError");
NSLog(error.localizedDescription);
NSLog(@"%@", error.localizedDescription);
_completion(error, nil);
_completion = nil;
}
Expand Down
12 changes: 10 additions & 2 deletions ios/RNAppleAuthentication/RNAppleAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,17 @@ + (BOOL)requiresMainQueueSetup {
}

- (NSDictionary *)constantsToExport {
bool supported = false;
if (@available(iOS 13.0, macOS 10.15, *)) {
supported = true;
}
bool signUpButtonSupported = false;
if (@available(iOS 13.2, macOS 10.15.1, *)) {
signUpButtonSupported = true;
}
return @{
@"isSupported": @available(iOS 13.0, macOS 10.15, *) ? @(YES) : @(NO),
@"isSignUpButtonSupported": @available(iOS 13.2, macOS 10.15.1, *) ? @(YES) : @(NO),
@"isSupported": @(supported),
@"isSignUpButtonSupported": @(signUpButtonSupported),
};
}

Expand Down

0 comments on commit fab5071

Please sign in to comment.