@@ -130,7 +130,7 @@ - (dispatch_queue_t)methodQueue
130130 return ;
131131 }
132132 [self authorizeWithConfiguration: configuration
133-
133+
134134 redirectUrl: redirectUrl
135135 clientId: clientId
136136 clientSecret: clientSecret
@@ -343,7 +343,7 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
343343 OIDAuthorizationRequest *request =
344344 [[OIDAuthorizationRequest alloc ] initWithConfiguration: configuration
345345 clientId: clientId
346-
346+
347347 clientSecret: clientSecret
348348 scope: [OIDScopeUtilities scopesWithArray: scopes]
349349 redirectURL: [NSURL URLWithString: redirectUrl]
@@ -371,12 +371,16 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
371371
372372 UIViewController *presentingViewController = appDelegate.window .rootViewController .view .window ? appDelegate.window .rootViewController : appDelegate.window .rootViewController .presentedViewController ;
373373
374+ if (!presentingViewController) {
375+ presentingViewController = RCTPresentedViewController ();
376+ }
377+
374378#if TARGET_OS_MACCATALYST
375379 id <OIDExternalUserAgent> externalUserAgent = nil ;
376380#elif TARGET_OS_IOS
377381 id <OIDExternalUserAgent> externalUserAgent = iosCustomBrowser != nil ? [self getCustomBrowser: iosCustomBrowser] : nil ;
378382#endif
379-
383+
380384 OIDAuthorizationCallback callback = ^(OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error) {
381385 typeof (self) strongSelf = weakSelf;
382386 strongSelf->_currentSession = nil ;
@@ -391,7 +395,7 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
391395 };
392396
393397 if (skipCodeExchange) {
394-
398+
395399 if (externalUserAgent != nil ) {
396400 _currentSession = [OIDAuthorizationService presentAuthorizationRequest: request
397401 externalUserAgent: externalUserAgent
@@ -425,14 +429,14 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
425429 [self getErrorMessage: error], error);
426430 }
427431 };
428-
432+
429433 if (externalUserAgent != nil ) {
430434 _currentSession = [OIDAuthState authStateByPresentingAuthorizationRequest: request
431435 externalUserAgent: externalUserAgent
432436 callback: callback];
433437 } else {
434-
435-
438+
439+
436440 if (@available (iOS 13 , *)) {
437441 _currentSession = [OIDAuthState authStateByPresentingAuthorizationRequest: request
438442 presentingViewController: presentingViewController
@@ -520,7 +524,7 @@ - (void)endSessionWithConfiguration: (OIDServiceConfiguration *) configuration
520524 id <OIDExternalUserAgent> externalUserAgent = iosCustomBrowser != nil ? [self getCustomBrowser: iosCustomBrowser] : [self getExternalUserAgentWithPresentingViewController: presentingViewController
521525 prefersEphemeralSession: prefersEphemeralSession];
522526#endif
523-
527+
524528 _currentSession = [OIDAuthorizationService presentEndSessionRequest: endSessionRequest
525529 externalUserAgent: externalUserAgent
526530 callback: ^(OIDEndSessionResponse *_Nullable response, NSError *_Nullable error) {
@@ -697,7 +701,7 @@ - (NSString*)getErrorCode: (NSError*) error defaultCode: (NSString *) defaultCod
697701#if !TARGET_OS_MACCATALYST
698702- (id <OIDExternalUserAgent>)getCustomBrowser : (NSString *) browserType {
699703 typedef id <OIDExternalUserAgent> (^BrowserBlock)(void );
700-
704+
701705 NSDictionary *browsers = @{
702706 @" safari" :
703707 ^{
0 commit comments