diff --git a/ios/OAuthManager/OAuthManager.m b/ios/OAuthManager/OAuthManager.m index a2c5230..9f33948 100644 --- a/ios/OAuthManager/OAuthManager.m +++ b/ios/OAuthManager/OAuthManager.m @@ -7,6 +7,7 @@ #import #import #import +#import #import "OAuthManager.h" #import "DCTAuth.h" @@ -29,6 +30,7 @@ @implementation OAuthManager static NSString *const AUTH_MANAGER_TAG = @"AUTH_MANAGER"; static OAuthManager *manager; static dispatch_once_t onceToken; +static SFSafariViewController *safariViewController = nil; RCT_EXPORT_MODULE(OAuthManager); @@ -85,7 +87,13 @@ + (BOOL)setupOAuthHandler:(UIApplication *)application [authPlatform setURLOpener: ^void(NSURL *URL, DCTAuthPlatformCompletion completion) { // [sharedManager setPendingAuthentication:YES]; - [application openURL:URL]; + if ([SFSafariViewController class] != nil) { + safariViewController = [[SFSafariViewController alloc] initWithURL:URL]; + UIViewController *viewController = application.keyWindow.rootViewController; + [viewController presentViewController:safariViewController animated:YES completion: nil]; + } else { + [application openURL:URL]; + } completion(YES); }]; @@ -112,6 +120,9 @@ + (BOOL)handleOpenUrl:(UIApplication *)application openURL:(NSURL *)url NSString *strUrl = [manager stringHost:url]; if ([manager.callbackUrls indexOfObject:strUrl] != NSNotFound) { + if(safariViewController != nil) { + [safariViewController dismissViewControllerAnimated:YES completion:nil]; + } return [DCTAuth handleURL:url]; }