navigator add openUrl

This commit is contained in:
pengfei.zhou
2020-04-01 15:19:37 +08:00
committed by osborn
parent 9c520e1dc5
commit 78d4f51314
12 changed files with 78 additions and 13 deletions

View File

@@ -49,4 +49,16 @@ - (void)pop:(NSDictionary *)params {
[self.doricContext.navigator doric_navigator_pop:animated];
});
}
- (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"];
}
});
}
@end