Skip to content

Commit 399936d

Browse files
DevmateDropRctExportMethod Botfacebook-github-bot
authored andcommitted
xplat/js/react-native-github/packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm
Reviewed By: cortinico Differential Revision: D115169143
1 parent fff4994 commit 399936d

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#import <FBReactNativeSpec/FBReactNativeSpec.h>
1111
#import <React/RCTBridge.h>
12+
#import <React/RCTConvert.h>
1213
#import <React/RCTLog.h>
1314
#import <React/RCTUtils.h>
1415

@@ -87,34 +88,36 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
8788
[self sendEventWithName:@"url" body:notification.userInfo];
8889
}
8990

90-
RCT_EXPORT_METHOD(
91-
openURL : (NSURL *)URL resolve : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject)
91+
- (void)openURL:(NSString *)urlString resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
9292
{
93+
NSURL *URL = [RCTConvert NSURL:urlString];
9394
[RCTSharedApplication() openURL:URL
94-
options:@{}
95-
completionHandler:^(BOOL success) {
96-
if (success) {
97-
resolve(@YES);
98-
} else {
95+
options:@{}
96+
completionHandler:^(BOOL success) {
97+
if (success) {
98+
resolve(@YES);
99+
} else {
99100
#if TARGET_OS_SIMULATOR
100-
// Simulator-specific code
101-
if ([URL.absoluteString hasPrefix:@"tel:"]) {
102-
RCTLogWarn(@"Unable to open the Phone app in the simulator for telephone URLs. URL: %@", URL);
103-
resolve(@NO);
104-
} else {
105-
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
106-
}
101+
// Simulator-specific code
102+
if ([URL.absoluteString hasPrefix:@"tel:"]) {
103+
RCTLogWarn(@"Unable to open the Phone app in the simulator for telephone URLs. URL: %@", URL);
104+
resolve(@NO);
105+
} else {
106+
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
107+
}
107108
#else
108109
// Device-specific code
109110
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
110111
#endif
111-
}
112-
}];
112+
}
113+
}];
113114
}
114115

115-
RCT_EXPORT_METHOD(
116-
canOpenURL : (NSURL *)URL resolve : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject)
116+
- (void)canOpenURL:(NSString *)urlString
117+
resolve:(RCTPromiseResolveBlock)resolve
118+
reject:(__unused RCTPromiseRejectBlock)reject
117119
{
120+
NSURL *URL = [RCTConvert NSURL:urlString];
118121
if (RCTRunningInAppExtension()) {
119122
// Technically Today widgets can open urls, but supporting that would require
120123
// a reference to the NSExtensionContext
@@ -148,7 +151,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
148151
}
149152
}
150153

151-
RCT_EXPORT_METHOD(getInitialURL : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject)
154+
- (void)getInitialURL:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject
152155
{
153156
NSURL *initialURL = nil;
154157
if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey] != nullptr) {
@@ -163,18 +166,18 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
163166
resolve(RCTNullIfNil(initialURL.absoluteString));
164167
}
165168

166-
RCT_EXPORT_METHOD(openSettings : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject)
169+
- (void)openSettings:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject
167170
{
168171
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
169172
[RCTSharedApplication() openURL:url
170-
options:@{}
171-
completionHandler:^(BOOL success) {
172-
if (success) {
173-
resolve(nil);
174-
} else {
175-
reject(RCTErrorUnspecified, @"Unable to open app settings", nil);
176-
}
177-
}];
173+
options:@{}
174+
completionHandler:^(BOOL success) {
175+
if (success) {
176+
resolve(nil);
177+
} else {
178+
reject(RCTErrorUnspecified, @"Unable to open app settings", nil);
179+
}
180+
}];
178181
}
179182

180183
RCT_EXPORT_METHOD(

0 commit comments

Comments
 (0)