mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 23:05:00 +08:00
Update openUrl (#23640)
Summary: Fix deprecation with openUrl, handles feedback in #17011. [iOS] [Fixed] - openUrl deprecation Pull Request resolved: https://github.com/facebook/react-native/pull/23640 Differential Revision: D14211015 Pulled By: hramos fbshipit-source-id: 9c8fa9f61aaa14542af9456dc39f6bfabd6a1405
This commit is contained in:
committed by
Facebook Github Bot
parent
cd7cc7d640
commit
fd3db03427
@@ -88,12 +88,23 @@ RCT_EXPORT_METHOD(openURL:(NSURL *)URL
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user