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 {
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *url = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
[promise resolve:nil];
} else {
[promise reject:@"Cannot open"];
}
[UIApplication.sharedApplication openURL:url options:@{} completionHandler:^(BOOL success) {
if (success) {
[promise resolve:nil];
} else {
[promise reject:@"Cannot open"];
}
}];
});
}
@end