iOS:openUrl do not check canOpenUrl

This commit is contained in:
pengfei.zhou 2020-09-03 14:56:13 +08:00 committed by osborn
parent c1f71ba4dc
commit a8cbdc0c1d

View File

@ -53,12 +53,13 @@ - (void)pop:(NSDictionary *)params {
- (void)openUrl:(NSString *)urlString withPromise:(DoricPromise *)promise { - (void)openUrl:(NSString *)urlString withPromise:(DoricPromise *)promise {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSURL *url = [NSURL URLWithString:urlString]; NSURL *url = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL:url]) { [UIApplication.sharedApplication openURL:url options:@{} completionHandler:^(BOOL success) {
[[UIApplication sharedApplication] openURL:url]; if (success) {
[promise resolve:nil]; [promise resolve:nil];
} else { } else {
[promise reject:@"Cannot open"]; [promise reject:@"Cannot open"];
} }
}];
}); });
} }
@end @end