Skip to content

Commit

Permalink
Update openUrl (#23640)
Browse files Browse the repository at this point in the history
Summary:
Fix deprecation with openUrl, handles feedback in #17011.

[iOS] [Fixed] - openUrl deprecation
Pull Request resolved: #23640

Differential Revision: D14211015

Pulled By: hramos

fbshipit-source-id: 9c8fa9f61aaa14542af9456dc39f6bfabd6a1405
  • Loading branch information
ericlewis authored and facebook-github-bot committed Feb 25, 2019
1 parent cd7cc7d commit fd3db03
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Libraries/LinkingIOS/RCTLinkingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,23 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
BOOL opened = [RCTSharedApplication() openURL:URL];
if (opened) {
resolve(nil);
if (@available(iOS 10.0, *)) {
[RCTSharedApplication() openURL:URL options:@{} completionHandler:^(BOOL success) {
if (success) {
resolve(nil);
} else {
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
}
}];
} else {
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
BOOL opened = [RCTSharedApplication() openURL:URL];
if (opened) {
resolve(nil);
} else {
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
}
}

}

RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
Expand Down

0 comments on commit fd3db03

Please sign in to comment.