|
15 | 15 | #import <AuthenticationServices/AuthenticationServices.h>
|
16 | 16 | #endif
|
17 | 17 |
|
18 |
| -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_13_0 |
19 |
| -@interface RNInAppBrowser () <SFSafariViewControllerDelegate, UIAdaptivePresentationControllerDelegate> |
20 |
| -@end |
21 |
| -#else |
| 18 | +#pragma clang diagnostic push |
| 19 | +#pragma clang diagnostic ignored "-Wpartial-availability" |
| 20 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
22 | 21 | @interface RNInAppBrowser () <SFSafariViewControllerDelegate, ASWebAuthenticationPresentationContextProviding, UIAdaptivePresentationControllerDelegate>
|
23 |
| -@end |
24 |
| -#endif |
25 |
| - |
26 |
| -@interface ModalSafariViewController () <UINavigationControllerDelegate> |
27 |
| -@end |
28 |
| - |
29 |
| -@implementation ModalSafariViewController |
30 |
| - |
31 |
| -- (void)viewDidLoad { |
32 |
| - [super viewDidLoad]; |
33 |
| -} |
34 |
| - |
35 |
| -- (void)viewWillAppear:(BOOL)animated { |
36 |
| - [super viewWillAppear:animated]; |
37 |
| -} |
38 |
| - |
39 |
| -- (void)viewDidDisappear:(BOOL)animated { |
40 |
| - [super viewDidDisappear:animated]; |
41 |
| -} |
42 |
| - |
43 |
| -- (BOOL)shouldAutorotate { |
44 |
| - return YES; |
45 |
| -} |
46 |
| - |
47 |
| -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < 90000 |
48 |
| -- (NSUInteger)supportedInterfaceOrientations |
49 | 22 | #else
|
50 |
| -- (UIInterfaceOrientationMask)supportedInterfaceOrientations |
| 23 | +@interface RNInAppBrowser () <SFSafariViewControllerDelegate, UIAdaptivePresentationControllerDelegate> |
51 | 24 | #endif
|
52 |
| -{ |
53 |
| - return UIInterfaceOrientationMaskAll; |
54 |
| -} |
55 |
| - |
56 |
| -- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { |
57 |
| - UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; |
58 |
| - return orientation; |
59 |
| -} |
60 |
| - |
61 | 25 | @end
|
| 26 | +#pragma clang diagnostic pop |
62 | 27 |
|
63 | 28 | NSString *RNInAppBrowserErrorCode = @"RNInAppBrowser";
|
64 | 29 |
|
65 | 30 | @implementation RNInAppBrowser
|
66 | 31 |
|
67 | 32 | #pragma clang diagnostic push
|
68 | 33 | #pragma clang diagnostic ignored "-Wpartial-availability"
|
69 |
| -static SFAuthenticationSession *sfAuthSession API_AVAILABLE(ios(11.0)) API_DEPRECATED("Use ASWebAuthenticationSession instead", ios(11.0, 12.0)); |
| 34 | +static SFAuthenticationSession *authSession API_AVAILABLE(ios(11.0)) API_DEPRECATED("Use ASWebAuthenticationSession instead", ios(11.0, 12.0)); |
70 | 35 | #pragma clang diagnostic pop
|
71 | 36 |
|
72 | 37 | #pragma clang diagnostic push
|
73 | 38 | #pragma clang diagnostic ignored "-Wpartial-availability"
|
74 |
| -static ASWebAuthenticationSession *authSession API_AVAILABLE(ios(12.0)); |
| 39 | +static ASWebAuthenticationSession *webAuthSession API_AVAILABLE(ios(12.0)); |
75 | 40 | #pragma clang diagnostic pop
|
76 | 41 |
|
77 | 42 | static SFSafariViewController *safariVC;
|
@@ -123,27 +88,29 @@ + (BOOL)requiresMainQueueSetup
|
123 | 88 | };
|
124 | 89 |
|
125 | 90 | if (@available(iOS 12.0, *)) {
|
126 |
| - authSession = [[ASWebAuthenticationSession alloc] |
| 91 | + webAuthSession = [[ASWebAuthenticationSession alloc] |
127 | 92 | initWithURL:url
|
128 | 93 | callbackURLScheme:redirectURL
|
129 | 94 | completionHandler:completionHandler];
|
130 | 95 | } else {
|
131 |
| - sfAuthSession = [[SFAuthenticationSession alloc] |
| 96 | + authSession = [[SFAuthenticationSession alloc] |
132 | 97 | initWithURL:url
|
133 | 98 | callbackURLScheme:redirectURL
|
134 | 99 | completionHandler:completionHandler];
|
135 | 100 | }
|
136 | 101 |
|
137 |
| -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
| 102 | +#pragma clang diagnostic push |
| 103 | +#pragma clang diagnostic ignored "-Wpartial-availability" |
| 104 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
138 | 105 | if (@available(iOS 13.0, *)) {
|
139 |
| - authSession.presentationContextProvider = self; |
| 106 | + webAuthSession.presentationContextProvider = self; |
140 | 107 | }
|
141 | 108 | #endif
|
142 |
| - |
| 109 | +#pragma clang diagnostic pop |
143 | 110 | if (@available(iOS 12.0, *)) {
|
144 |
| - [authSession start]; |
| 111 | + [webAuthSession start]; |
145 | 112 | } else {
|
146 |
| - [sfAuthSession start]; |
| 113 | + [authSession start]; |
147 | 114 | }
|
148 | 115 | } else {
|
149 | 116 | resolve(@{
|
@@ -209,19 +176,25 @@ + (BOOL)requiresMainQueueSetup
|
209 | 176 | UIViewController *ctrl = RCTPresentedViewController();
|
210 | 177 | if (modalEnabled) {
|
211 | 178 | // This is a hack to present the SafariViewController modally
|
212 |
| - UINavigationController *safariHackVC = [[ModalSafariViewController alloc] initWithRootViewController:safariVC]; |
| 179 | + UINavigationController *safariHackVC = [[UINavigationController alloc] initWithRootViewController:safariVC]; |
213 | 180 | [safariHackVC setNavigationBarHidden:true animated:false];
|
214 | 181 |
|
| 182 | + // To disable "Swipe to dismiss" gesture which sometimes causes a bug where `safariViewControllerDidFinish` |
| 183 | + // is not called. |
| 184 | + safariVC.modalPresentationStyle = UIModalPresentationOverFullScreen; |
215 | 185 | safariHackVC.modalPresentationStyle = [self getPresentationStyle: modalPresentationStyle];
|
216 | 186 | if(animated) {
|
217 | 187 | safariHackVC.modalTransitionStyle = [self getTransitionStyle: modalTransitionStyle];
|
218 | 188 | }
|
219 | 189 | safariHackVC.presentationController.delegate = self;
|
220 |
| -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
| 190 | +#pragma clang diagnostic push |
| 191 | +#pragma clang diagnostic ignored "-Wpartial-availability" |
| 192 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
221 | 193 | if (@available(iOS 13.0, *)) {
|
222 | 194 | [safariHackVC setModalInPresentation:TRUE];
|
223 | 195 | }
|
224 | 196 | #endif
|
| 197 | +#pragma clang diagnostic pop |
225 | 198 | [ctrl presentViewController:safariHackVC animated:animated completion:nil];
|
226 | 199 | }
|
227 | 200 | else {
|
@@ -268,9 +241,9 @@ - (void)_close
|
268 | 241 | [self flowDidFinish];
|
269 | 242 | }
|
270 | 243 | if (@available(iOS 12.0, *)) {
|
271 |
| - [authSession cancel]; |
| 244 | + [webAuthSession cancel]; |
272 | 245 | } else {
|
273 |
| - [sfAuthSession cancel]; |
| 246 | + [authSession cancel]; |
274 | 247 | }
|
275 | 248 | } else {
|
276 | 249 | [self close];
|
@@ -334,12 +307,15 @@ - (UIModalPresentationStyle)getPresentationStyle:(NSString *)styleKey {
|
334 | 307 | @"overCurrentContext": @(UIModalPresentationOverCurrentContext),
|
335 | 308 | @"popover": @(UIModalPresentationPopover)
|
336 | 309 | };
|
| 310 | +#pragma clang diagnostic push |
| 311 | +#pragma clang diagnostic ignored "-Wpartial-availability" |
337 | 312 | UIModalPresentationStyle modalPresentationStyle = UIModalPresentationFullScreen;
|
338 |
| -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
| 313 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
339 | 314 | if (@available(iOS 13.0, *)) {
|
340 | 315 | modalPresentationStyle = UIModalPresentationAutomatic;
|
341 | 316 | }
|
342 | 317 | #endif
|
| 318 | +#pragma clang diagnostic pop |
343 | 319 | NSNumber *style = [styles objectForKey: styleKey];
|
344 | 320 | if (style != nil) {
|
345 | 321 | modalPresentationStyle = [style intValue];
|
|
0 commit comments