Skip to content

Commit 886e67a

Browse files
author
Kadi Kraman
authored
Merge pull request #544 from FormidableLabs/bugfix/ios-presenting-view-controller
Add a fallback for presenting view controller on ios
2 parents acfd11b + 54951bc commit 886e67a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ios/RNAppAuth.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,11 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
301301
taskId = UIBackgroundTaskInvalid;
302302
}];
303303

304+
UIViewController *presentingViewController = appDelegate.window.rootViewController.view.window ? appDelegate.window.rootViewController : appDelegate.window.rootViewController.presentedViewController;
305+
304306
if (skipCodeExchange) {
305307
_currentSession = [OIDAuthorizationService presentAuthorizationRequest:request
306-
presentingViewController:appDelegate.window.rootViewController
308+
presentingViewController:presentingViewController
307309
callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error) {
308310
typeof(self) strongSelf = weakSelf;
309311
strongSelf->_currentSession = nil;
@@ -318,7 +320,7 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
318320
}]; // end [OIDAuthState presentAuthorizationRequest:request
319321
} else {
320322
_currentSession = [OIDAuthState authStateByPresentingAuthorizationRequest:request
321-
presentingViewController:appDelegate.window.rootViewController
323+
presentingViewController:presentingViewController
322324
callback:^(OIDAuthState *_Nullable authState,
323325
NSError *_Nullable error) {
324326
typeof(self) strongSelf = weakSelf;

0 commit comments

Comments
 (0)