Skip to content

Commit 3b7fd96

Browse files
committed
Remove build warnings with iOS 13 using Pragmas
1 parent c51cff4 commit 3b7fd96

File tree

2 files changed

+27
-57
lines changed

2 files changed

+27
-57
lines changed

ios/RNInAppBrowser.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@
55
#endif
66

77
@interface RNInAppBrowser : NSObject <RCTBridgeModule>
8-
@end
9-
10-
@interface ModalSafariViewController : UINavigationController <UINavigationControllerDelegate>
11-
@end
8+
@end

ios/RNInAppBrowser.m

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,28 @@
1515
#import <AuthenticationServices/AuthenticationServices.h>
1616
#endif
1717

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
1921
@interface RNInAppBrowser () <SFSafariViewControllerDelegate, UIAdaptivePresentationControllerDelegate>
20-
@end
2122
#else
2223
@interface RNInAppBrowser () <SFSafariViewControllerDelegate, ASWebAuthenticationPresentationContextProviding, UIAdaptivePresentationControllerDelegate>
23-
@end
2424
#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-
6125
@end
26+
#pragma clang diagnostic pop
6227

6328
NSString *RNInAppBrowserErrorCode = @"RNInAppBrowser";
6429

6530
@implementation RNInAppBrowser
6631

6732
#pragma clang diagnostic push
6833
#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));
7035
#pragma clang diagnostic pop
7136

7237
#pragma clang diagnostic push
7338
#pragma clang diagnostic ignored "-Wpartial-availability"
74-
static ASWebAuthenticationSession *authSession API_AVAILABLE(ios(12.0));
39+
static ASWebAuthenticationSession *webAuthSession API_AVAILABLE(ios(12.0));
7540
#pragma clang diagnostic pop
7641

7742
static SFSafariViewController *safariVC;
@@ -123,27 +88,29 @@ + (BOOL)requiresMainQueueSetup
12388
};
12489

12590
if (@available(iOS 12.0, *)) {
126-
authSession = [[ASWebAuthenticationSession alloc]
91+
webAuthSession = [[ASWebAuthenticationSession alloc]
12792
initWithURL:url
12893
callbackURLScheme:redirectURL
12994
completionHandler:completionHandler];
13095
} else {
131-
sfAuthSession = [[SFAuthenticationSession alloc]
96+
authSession = [[SFAuthenticationSession alloc]
13297
initWithURL:url
13398
callbackURLScheme:redirectURL
13499
completionHandler:completionHandler];
135100
}
136101

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
138105
if (@available(iOS 13.0, *)) {
139-
authSession.presentationContextProvider = self;
106+
webAuthSession.presentationContextProvider = self;
140107
}
141108
#endif
142-
109+
#pragma clang diagnostic pop
143110
if (@available(iOS 12.0, *)) {
144-
[authSession start];
111+
[webAuthSession start];
145112
} else {
146-
[sfAuthSession start];
113+
[authSession start];
147114
}
148115
} else {
149116
resolve(@{
@@ -209,19 +176,22 @@ + (BOOL)requiresMainQueueSetup
209176
UIViewController *ctrl = RCTPresentedViewController();
210177
if (modalEnabled) {
211178
// This is a hack to present the SafariViewController modally
212-
UINavigationController *safariHackVC = [[ModalSafariViewController alloc] initWithRootViewController:safariVC];
179+
UINavigationController *safariHackVC = [[UINavigationController alloc] initWithRootViewController:safariVC];
213180
[safariHackVC setNavigationBarHidden:true animated:false];
214181

215182
safariHackVC.modalPresentationStyle = [self getPresentationStyle: modalPresentationStyle];
216183
if(animated) {
217184
safariHackVC.modalTransitionStyle = [self getTransitionStyle: modalTransitionStyle];
218185
}
219186
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
221190
if (@available(iOS 13.0, *)) {
222191
[safariHackVC setModalInPresentation:TRUE];
223192
}
224193
#endif
194+
#pragma clang diagnostic pop
225195
[ctrl presentViewController:safariHackVC animated:animated completion:nil];
226196
}
227197
else {
@@ -268,9 +238,9 @@ - (void)_close
268238
[self flowDidFinish];
269239
}
270240
if (@available(iOS 12.0, *)) {
271-
[authSession cancel];
241+
[webAuthSession cancel];
272242
} else {
273-
[sfAuthSession cancel];
243+
[authSession cancel];
274244
}
275245
} else {
276246
[self close];
@@ -334,12 +304,15 @@ - (UIModalPresentationStyle)getPresentationStyle:(NSString *)styleKey {
334304
@"overCurrentContext": @(UIModalPresentationOverCurrentContext),
335305
@"popover": @(UIModalPresentationPopover)
336306
};
307+
#pragma clang diagnostic push
308+
#pragma clang diagnostic ignored "-Wpartial-availability"
337309
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
339311
if (@available(iOS 13.0, *)) {
340312
modalPresentationStyle = UIModalPresentationAutomatic;
341313
}
342314
#endif
315+
#pragma clang diagnostic pop
343316
NSNumber *style = [styles objectForKey: styleKey];
344317
if (style != nil) {
345318
modalPresentationStyle = [style intValue];

0 commit comments

Comments
 (0)