Skip to content

Commit 58a6a40

Browse files
fkgozalifacebook-github-bot
authored andcommitted
Re-land [RN] iOS - deprecate iOS 9 support by removing runtime checks for 10.0+
Summary: Re-landing the reverted change: This removes all callsites that rely on runtime checks to detect the target deployment version. We no longer need to check for iOS 10+ in a few places. Note: for this to compile, the hosting app needs to target iOS 10.0+. Changelog: [iOS] [Deprecated] - Deprecate iOS 9 Reviewed By: sammy-SC Differential Revision: D19411136 fbshipit-source-id: ec0a957dc57819f0ee7d138c858209cabe3e5102
1 parent f11937e commit 58a6a40

File tree

5 files changed

+87
-138
lines changed

5 files changed

+87
-138
lines changed

Libraries/LinkingIOS/RCTLinkingManager.mm

+10-46
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,8 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
9999
resolve:(RCTPromiseResolveBlock)resolve
100100
reject:(RCTPromiseRejectBlock)reject)
101101
{
102-
if (@available(iOS 10.0, *)) {
103-
[RCTSharedApplication() openURL:URL options:@{} completionHandler:^(BOOL success) {
104-
if (success) {
105-
resolve(@YES);
106-
} else {
107-
#if TARGET_OS_SIMULATOR
108-
// Simulator-specific code
109-
if([URL.absoluteString hasPrefix:@"tel:"]){
110-
RCTLogWarn(@"Unable to open the Phone app in the simulator for telephone URLs. URL: %@", URL);
111-
resolve(@NO);
112-
} else {
113-
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
114-
}
115-
#else
116-
// Device-specific code
117-
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
118-
#endif
119-
}
120-
}];
121-
} else {
122-
#if !TARGET_OS_UIKITFORMAC
123-
// Note: this branch will never be taken on UIKitForMac
124-
BOOL opened = [RCTSharedApplication() openURL:URL];
125-
if (opened) {
102+
[RCTSharedApplication() openURL:URL options:@{} completionHandler:^(BOOL success) {
103+
if (success) {
126104
resolve(@YES);
127105
} else {
128106
#if TARGET_OS_SIMULATOR
@@ -138,9 +116,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
138116
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
139117
#endif
140118
}
141-
#endif
142-
}
143-
119+
}];
144120
}
145121

146122
RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
@@ -193,25 +169,13 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
193169
reject:(__unused RCTPromiseRejectBlock)reject)
194170
{
195171
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
196-
if (@available(iOS 10.0, *)) {
197-
[RCTSharedApplication() openURL:url options:@{} completionHandler:^(BOOL success) {
198-
if (success) {
199-
resolve(nil);
200-
} else {
201-
reject(RCTErrorUnspecified, @"Unable to open app settings", nil);
202-
}
203-
}];
204-
} else {
205-
#if !TARGET_OS_UIKITFORMAC
206-
// Note: This branch will never be taken on UIKitForMac
207-
BOOL opened = [RCTSharedApplication() openURL:url];
208-
if (opened) {
209-
resolve(nil);
210-
} else {
211-
reject(RCTErrorUnspecified, @"Unable to open app settings", nil);
212-
}
213-
#endif
214-
}
172+
[RCTSharedApplication() openURL:url options:@{} completionHandler:^(BOOL success) {
173+
if (success) {
174+
resolve(nil);
175+
} else {
176+
reject(RCTErrorUnspecified, @"Unable to open app settings", nil);
177+
}
178+
}];
215179
}
216180

217181
RCT_EXPORT_METHOD(sendIntent:(NSString *)action

Libraries/PushNotificationIOS/RCTPushNotificationManager.mm

+12-21
Original file line numberDiff line numberDiff line change
@@ -472,36 +472,27 @@ - (void)handleRegisterUserNotificationSettings:(NSNotification *)notification
472472

473473
RCT_EXPORT_METHOD(removeAllDeliveredNotifications)
474474
{
475-
// TODO: T56867629
476-
if (@available(iOS 10.0, tvOS 10.0, *)) {
477-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
478-
[center removeAllDeliveredNotifications];
479-
}
475+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
476+
[center removeAllDeliveredNotifications];
480477
}
481478

482479
RCT_EXPORT_METHOD(removeDeliveredNotifications:(NSArray<NSString *> *)identifiers)
483480
{
484-
// TODO: T56867629
485-
if (@available(iOS 10.0, tvOS 10.0, *)) {
486-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
487-
[center removeDeliveredNotificationsWithIdentifiers:identifiers];
488-
}
481+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
482+
[center removeDeliveredNotificationsWithIdentifiers:identifiers];
489483
}
490484

491485
RCT_EXPORT_METHOD(getDeliveredNotifications:(RCTResponseSenderBlock)callback)
492486
{
493-
// TODO: T56867629
494-
if (@available(iOS 10.0, tvOS 10.0, *)) {
495-
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
496-
[center getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> *_Nonnull notifications) {
497-
NSMutableArray<NSDictionary *> *formattedNotifications = [NSMutableArray new];
487+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
488+
[center getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> *_Nonnull notifications) {
489+
NSMutableArray<NSDictionary *> *formattedNotifications = [NSMutableArray new];
498490

499-
for (UNNotification *notification in notifications) {
500-
[formattedNotifications addObject:RCTFormatUNNotification(notification)];
501-
}
502-
callback(@[formattedNotifications]);
503-
}];
504-
}
491+
for (UNNotification *notification in notifications) {
492+
[formattedNotifications addObject:RCTFormatUNNotification(notification)];
493+
}
494+
callback(@[formattedNotifications]);
495+
}];
505496
}
506497

507498
#else //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

Libraries/Text/TextInput/RCTBaseTextInputView.m

+59-62
Original file line numberDiff line numberDiff line change
@@ -194,68 +194,65 @@ - (void)setSelection:(RCTTextSelection *)selection
194194

195195
- (void)setTextContentType:(NSString *)type
196196
{
197-
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
198-
if (@available(iOS 10.0, *)) {
199-
200-
static dispatch_once_t onceToken;
201-
static NSDictionary<NSString *, NSString *> *contentTypeMap;
202-
203-
dispatch_once(&onceToken, ^{
204-
contentTypeMap = @{@"none": @"",
205-
@"URL": UITextContentTypeURL,
206-
@"addressCity": UITextContentTypeAddressCity,
207-
@"addressCityAndState":UITextContentTypeAddressCityAndState,
208-
@"addressState": UITextContentTypeAddressState,
209-
@"countryName": UITextContentTypeCountryName,
210-
@"creditCardNumber": UITextContentTypeCreditCardNumber,
211-
@"emailAddress": UITextContentTypeEmailAddress,
212-
@"familyName": UITextContentTypeFamilyName,
213-
@"fullStreetAddress": UITextContentTypeFullStreetAddress,
214-
@"givenName": UITextContentTypeGivenName,
215-
@"jobTitle": UITextContentTypeJobTitle,
216-
@"location": UITextContentTypeLocation,
217-
@"middleName": UITextContentTypeMiddleName,
218-
@"name": UITextContentTypeName,
219-
@"namePrefix": UITextContentTypeNamePrefix,
220-
@"nameSuffix": UITextContentTypeNameSuffix,
221-
@"nickname": UITextContentTypeNickname,
222-
@"organizationName": UITextContentTypeOrganizationName,
223-
@"postalCode": UITextContentTypePostalCode,
224-
@"streetAddressLine1": UITextContentTypeStreetAddressLine1,
225-
@"streetAddressLine2": UITextContentTypeStreetAddressLine2,
226-
@"sublocality": UITextContentTypeSublocality,
227-
@"telephoneNumber": UITextContentTypeTelephoneNumber,
228-
};
229-
230-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
231-
if (@available(iOS 11.0, tvOS 11.0, *)) {
232-
NSDictionary<NSString *, NSString *> * iOS11extras = @{@"username": UITextContentTypeUsername,
233-
@"password": UITextContentTypePassword};
234-
235-
NSMutableDictionary<NSString *, NSString *> * iOS11baseMap = [contentTypeMap mutableCopy];
236-
[iOS11baseMap addEntriesFromDictionary:iOS11extras];
237-
238-
contentTypeMap = [iOS11baseMap copy];
239-
}
240-
#endif
241-
242-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 /* __IPHONE_12_0 */
243-
if (@available(iOS 12.0, tvOS 12.0, *)) {
244-
NSDictionary<NSString *, NSString *> * iOS12extras = @{@"newPassword": UITextContentTypeNewPassword,
245-
@"oneTimeCode": UITextContentTypeOneTimeCode};
246-
247-
NSMutableDictionary<NSString *, NSString *> * iOS12baseMap = [contentTypeMap mutableCopy];
248-
[iOS12baseMap addEntriesFromDictionary:iOS12extras];
249-
250-
contentTypeMap = [iOS12baseMap copy];
251-
}
252-
#endif
253-
});
254-
255-
// Setting textContentType to an empty string will disable any
256-
// default behaviour, like the autofill bar for password inputs
257-
self.backedTextInputView.textContentType = contentTypeMap[type] ?: type;
258-
}
197+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
198+
static dispatch_once_t onceToken;
199+
static NSDictionary<NSString *, NSString *> *contentTypeMap;
200+
201+
dispatch_once(&onceToken, ^{
202+
contentTypeMap = @{@"none": @"",
203+
@"URL": UITextContentTypeURL,
204+
@"addressCity": UITextContentTypeAddressCity,
205+
@"addressCityAndState":UITextContentTypeAddressCityAndState,
206+
@"addressState": UITextContentTypeAddressState,
207+
@"countryName": UITextContentTypeCountryName,
208+
@"creditCardNumber": UITextContentTypeCreditCardNumber,
209+
@"emailAddress": UITextContentTypeEmailAddress,
210+
@"familyName": UITextContentTypeFamilyName,
211+
@"fullStreetAddress": UITextContentTypeFullStreetAddress,
212+
@"givenName": UITextContentTypeGivenName,
213+
@"jobTitle": UITextContentTypeJobTitle,
214+
@"location": UITextContentTypeLocation,
215+
@"middleName": UITextContentTypeMiddleName,
216+
@"name": UITextContentTypeName,
217+
@"namePrefix": UITextContentTypeNamePrefix,
218+
@"nameSuffix": UITextContentTypeNameSuffix,
219+
@"nickname": UITextContentTypeNickname,
220+
@"organizationName": UITextContentTypeOrganizationName,
221+
@"postalCode": UITextContentTypePostalCode,
222+
@"streetAddressLine1": UITextContentTypeStreetAddressLine1,
223+
@"streetAddressLine2": UITextContentTypeStreetAddressLine2,
224+
@"sublocality": UITextContentTypeSublocality,
225+
@"telephoneNumber": UITextContentTypeTelephoneNumber,
226+
};
227+
228+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
229+
if (@available(iOS 11.0, tvOS 11.0, *)) {
230+
NSDictionary<NSString *, NSString *> * iOS11extras = @{@"username": UITextContentTypeUsername,
231+
@"password": UITextContentTypePassword};
232+
233+
NSMutableDictionary<NSString *, NSString *> * iOS11baseMap = [contentTypeMap mutableCopy];
234+
[iOS11baseMap addEntriesFromDictionary:iOS11extras];
235+
236+
contentTypeMap = [iOS11baseMap copy];
237+
}
238+
#endif
239+
240+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 /* __IPHONE_12_0 */
241+
if (@available(iOS 12.0, tvOS 12.0, *)) {
242+
NSDictionary<NSString *, NSString *> * iOS12extras = @{@"newPassword": UITextContentTypeNewPassword,
243+
@"oneTimeCode": UITextContentTypeOneTimeCode};
244+
245+
NSMutableDictionary<NSString *, NSString *> * iOS12baseMap = [contentTypeMap mutableCopy];
246+
[iOS12baseMap addEntriesFromDictionary:iOS12extras];
247+
248+
contentTypeMap = [iOS12baseMap copy];
249+
}
250+
#endif
251+
});
252+
253+
// Setting textContentType to an empty string will disable any
254+
// default behaviour, like the autofill bar for password inputs
255+
self.backedTextInputView.textContentType = contentTypeMap[type] ?: type;
259256
#endif
260257
}
261258

React/Base/RCTConvert.m

+4-7
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,10 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
363363
// Added for Android compatibility
364364
@"numeric": @(UIKeyboardTypeDecimalPad),
365365
}];
366-
// TODO: T56867629
367-
if (@available(iOS 10.0, tvOS 10.0, *)) {
368-
temporaryMapping[@"ascii-capable-number-pad"] = @(UIKeyboardTypeASCIICapableNumberPad);
369-
}
366+
temporaryMapping[@"ascii-capable-number-pad"] = @(UIKeyboardTypeASCIICapableNumberPad);
370367
mapping = temporaryMapping;
371368
});
372-
369+
373370
UIKeyboardType type = RCTConvertEnumValue("UIKeyboardType", mapping, @(UIKeyboardTypeDefault), json).integerValue;
374371
return type;
375372
}
@@ -445,7 +442,7 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
445442
@"default": @(UIBarStyleDefault),
446443
@"black": @(UIBarStyleBlack),
447444
@"blackOpaque": @(UIBarStyleBlackOpaque),
448-
@"blackTranslucent": @(UIBarStyleBlackTranslucent),
445+
@"blackTranslucent": @(UIBarStyleBlackTranslucent),
449446
}), UIBarStyleDefault, integerValue)
450447
#endif
451448

@@ -788,7 +785,7 @@ + (UIImage *)UIImage:(id)json
788785
// This check is added here instead of being inside RCTImageFromLocalAssetURL, since
789786
// we don't want breaking changes to RCTImageFromLocalAssetURL, which is called in a lot of places
790787
// This is a deprecated method, and hence has the least impact on existing code. Basically,
791-
// instead of crashing the app, it tries one more location for the image.
788+
// instead of crashing the app, it tries one more location for the image.
792789
if (!image) {
793790
image = RCTImageFromLocalBundleAssetURL(URL);
794791
}

React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ - (void)_attach
132132
return;
133133
}
134134

135-
if (@available(iOS 10.0, macOS 13.0, *)) {
135+
if (@available(macOS 13.0, *)) {
136136
_scrollViewComponentView.scrollView.refreshControl = _refreshControl;
137137
}
138138
}
@@ -146,7 +146,7 @@ - (void)_detach
146146
// iOS requires to end refreshing before unmounting.
147147
[_refreshControl endRefreshing];
148148

149-
if (@available(iOS 10.0, macOS 13.0, *)) {
149+
if (@available(macOS 13.0, *)) {
150150
_scrollViewComponentView.scrollView.refreshControl = nil;
151151
}
152152
_scrollViewComponentView = nil;

0 commit comments

Comments
 (0)