7
7
#import < Foundation/Foundation.h>
8
8
#import < UIKit/UIKit.h>
9
9
#import < objc/runtime.h>
10
+ #import < SafariServices/SafariServices.h>
10
11
11
12
#import " OAuthManager.h"
12
13
#import " DCTAuth.h"
@@ -29,6 +30,7 @@ @implementation OAuthManager
29
30
static NSString *const AUTH_MANAGER_TAG = @" AUTH_MANAGER" ;
30
31
static OAuthManager *manager;
31
32
static dispatch_once_t onceToken;
33
+ static SFSafariViewController *safariViewController = nil ;
32
34
33
35
RCT_EXPORT_MODULE (OAuthManager);
34
36
@@ -85,7 +87,13 @@ + (BOOL)setupOAuthHandler:(UIApplication *)application
85
87
86
88
[authPlatform setURLOpener: ^void (NSURL *URL, DCTAuthPlatformCompletion completion) {
87
89
// [sharedManager setPendingAuthentication:YES];
88
- [application openURL: URL];
90
+ if ([SFSafariViewController class ] != nil ) {
91
+ safariViewController = [[SFSafariViewController alloc ] initWithURL: URL];
92
+ UIViewController *viewController = application.keyWindow .rootViewController ;
93
+ [viewController presentViewController: safariViewController animated: YES completion: nil ];
94
+ } else {
95
+ [application openURL: URL];
96
+ }
89
97
completion (YES );
90
98
}];
91
99
@@ -112,6 +120,9 @@ + (BOOL)handleOpenUrl:(UIApplication *)application openURL:(NSURL *)url
112
120
NSString *strUrl = [manager stringHost: url];
113
121
114
122
if ([manager.callbackUrls indexOfObject: strUrl] != NSNotFound ) {
123
+ if (safariViewController != nil ) {
124
+ [safariViewController dismissViewControllerAnimated: YES completion: nil ];
125
+ }
115
126
return [DCTAuth handleURL: url];
116
127
}
117
128
0 commit comments