|
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 |
| 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 |
19 | 21 | @interface RNInAppBrowser () <SFSafariViewControllerDelegate, UIAdaptivePresentationControllerDelegate> |
20 | | -@end |
21 | 22 | #else |
22 | 23 | @interface RNInAppBrowser () <SFSafariViewControllerDelegate, ASWebAuthenticationPresentationContextProviding, UIAdaptivePresentationControllerDelegate> |
23 | | -@end |
24 | 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 | | -#else |
50 | | -- (UIInterfaceOrientationMask)supportedInterfaceOrientations |
51 | | -#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,22 @@ + (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 |
|
215 | 182 | safariHackVC.modalPresentationStyle = [self getPresentationStyle: modalPresentationStyle]; |
216 | 183 | if(animated) { |
217 | 184 | safariHackVC.modalTransitionStyle = [self getTransitionStyle: modalTransitionStyle]; |
218 | 185 | } |
219 | 186 | safariHackVC.presentationController.delegate = self; |
220 | | -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
| 187 | +#pragma clang diagnostic push |
| 188 | +#pragma clang diagnostic ignored "-Wpartial-availability" |
| 189 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
221 | 190 | if (@available(iOS 13.0, *)) { |
222 | 191 | [safariHackVC setModalInPresentation:TRUE]; |
223 | 192 | } |
224 | 193 | #endif |
| 194 | +#pragma clang diagnostic pop |
225 | 195 | [ctrl presentViewController:safariHackVC animated:animated completion:nil]; |
226 | 196 | } |
227 | 197 | else { |
@@ -268,9 +238,9 @@ - (void)_close |
268 | 238 | [self flowDidFinish]; |
269 | 239 | } |
270 | 240 | if (@available(iOS 12.0, *)) { |
271 | | - [authSession cancel]; |
| 241 | + [webAuthSession cancel]; |
272 | 242 | } else { |
273 | | - [sfAuthSession cancel]; |
| 243 | + [authSession cancel]; |
274 | 244 | } |
275 | 245 | } else { |
276 | 246 | [self close]; |
@@ -334,12 +304,15 @@ - (UIModalPresentationStyle)getPresentationStyle:(NSString *)styleKey { |
334 | 304 | @"overCurrentContext": @(UIModalPresentationOverCurrentContext), |
335 | 305 | @"popover": @(UIModalPresentationPopover) |
336 | 306 | }; |
| 307 | +#pragma clang diagnostic push |
| 308 | +#pragma clang diagnostic ignored "-Wpartial-availability" |
337 | 309 | UIModalPresentationStyle modalPresentationStyle = UIModalPresentationFullScreen; |
338 | | -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
| 310 | +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 |
339 | 311 | if (@available(iOS 13.0, *)) { |
340 | 312 | modalPresentationStyle = UIModalPresentationAutomatic; |
341 | 313 | } |
342 | 314 | #endif |
| 315 | +#pragma clang diagnostic pop |
343 | 316 | NSNumber *style = [styles objectForKey: styleKey]; |
344 | 317 | if (style != nil) { |
345 | 318 | modalPresentationStyle = [style intValue]; |
|
0 commit comments