Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Libraries/LinkingIOS/RCTLinkingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
BOOL opened = [RCTSharedApplication() openURL:URL];
BOOL opened = RCTLinkingIOSOpenUrl(URL);
if (opened) {
resolve(nil);
} else {
Expand All @@ -114,7 +114,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
// simply resolving with NO

// This can be expensive, so we deliberately don't call on main thread
BOOL canOpen = [RCTSharedApplication() canOpenURL:URL];
BOOL canOpen = RCTLinkingIOSCanOpenUrl(URL);
resolve(@(canOpen));
}

Expand Down
6 changes: 6 additions & 0 deletions React/Base/RCTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ RCT_EXTERN NSString *const RCTErrorUnspecified;
// Returns YES if React is running in a test environment
RCT_EXTERN BOOL RCTRunningInTestEnvironment(void);

// Returns the boolean output of UIApplication openUrl, or false if running in an App Extension
RCT_EXTERN BOOL RCTLinkingIOSOpenUrl(NSURL *URL);

// Returns the boolean output of UIApplication canOpenUrl, or false if running in an App Extension
RCT_EXTERN BOOL RCTLinkingIOSCanOpenUrl(NSURL *URL);

// Returns YES if React is running in an iOS App Extension
RCT_EXTERN BOOL RCTRunningInAppExtension(void);

Expand Down
16 changes: 16 additions & 0 deletions React/Base/RCTUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,22 @@ BOOL RCTRunningInAppExtension(void)
return [[[[NSBundle mainBundle] bundlePath] pathExtension] isEqualToString:@"appex"];
}

BOOL RCTLinkingIOSOpenUrl(NSURL *URL)
{
if (RCTRunningInAppExtension()) {
return false;
}
return [RCTSharedApplication() performSelector:@selector(openURL:) withObject: URL];
}

BOOL RCTLinkingIOSCanOpenUrl(NSURL *URL)
{
if (RCTRunningInAppExtension()) {
return false;
}
return [RCTSharedApplication() performSelector:@selector(canOpenURL:) withObject: URL];
}

UIApplication *__nullable RCTSharedApplication(void)
{
if (RCTRunningInAppExtension()) {
Expand Down