Skip to content

Commit 6ff6eff

Browse files
authored
Fix #857 by adding additional preprocessor directives for OS version. (#858)
* Update RNAppAuth.m * Update RNAppAuth.m with similar functionality provided prior.
1 parent 8a3f63c commit 6ff6eff

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ios/RNAppAuth.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,12 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
370370
}];
371371

372372
UIViewController *presentingViewController = appDelegate.window.rootViewController.view.window ? appDelegate.window.rootViewController : appDelegate.window.rootViewController.presentedViewController;
373+
374+
#if TARGET_OS_MACCATALYST
375+
id<OIDExternalUserAgent> externalUserAgent = nil;
376+
#elif TARGET_OS_IOS
373377
id<OIDExternalUserAgent> externalUserAgent = iosCustomBrowser != nil ? [self getCustomBrowser: iosCustomBrowser] : nil;
378+
#endif
374379

375380
OIDAuthorizationCallback callback = ^(OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error) {
376381
typeof(self) strongSelf = weakSelf;
@@ -504,10 +509,14 @@ - (void)endSessionWithConfiguration: (OIDServiceConfiguration *) configuration
504509
}];
505510

506511
UIViewController *presentingViewController = appDelegate.window.rootViewController.view.window ? appDelegate.window.rootViewController : appDelegate.window.rootViewController.presentedViewController;
507-
508-
id<OIDExternalUserAgent> externalUserAgent = iosCustomBrowser != nil ? [self getCustomBrowser: iosCustomBrowser] : [self getExternalUserAgentWithPresentingViewController:presentingViewController
509-
prefersEphemeralSession:prefersEphemeralSession];
510512

513+
#if TARGET_OS_MACCATALYST
514+
id<OIDExternalUserAgent> externalUserAgent = nil;
515+
#elif TARGET_OS_IOS
516+
id<OIDExternalUserAgent> externalUserAgent = iosCustomBrowser != nil ? [self getCustomBrowser: iosCustomBrowser] : [self getExternalUserAgentWithPresentingViewController:presentingViewController
517+
prefersEphemeralSession:prefersEphemeralSession];
518+
#endif
519+
511520
_currentSession = [OIDAuthorizationService presentEndSessionRequest: endSessionRequest
512521
externalUserAgent: externalUserAgent
513522
callback: ^(OIDEndSessionResponse *_Nullable response, NSError *_Nullable error) {
@@ -681,6 +690,7 @@ - (NSString*)getErrorCode: (NSError*) error defaultCode: (NSString *) defaultCod
681690
return defaultCode;
682691
}
683692

693+
#if !TARGET_OS_MACCATALYST
684694
- (id<OIDExternalUserAgent>)getCustomBrowser: (NSString *) browserType {
685695
typedef id<OIDExternalUserAgent> (^BrowserBlock)(void);
686696

@@ -705,6 +715,7 @@ - (NSString*)getErrorCode: (NSError*) error defaultCode: (NSString *) defaultCod
705715
BrowserBlock browser = browsers[browserType];
706716
return browser();
707717
}
718+
#endif
708719

709720
- (NSString*)getErrorMessage: (NSError*) error {
710721
NSDictionary * userInfo = [error userInfo];

0 commit comments

Comments
 (0)