- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
ifdef BGY_FLAG
if ([navigationAction.request.URL.absoluteString containsString:@"?no_intercept"]) {
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
}
else if ([navigationAction.request.URL.absoluteString hasPrefix:@"weixin"])
{
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
}
NSURL *url = navigationAction.request.URL;
UIApplication *app = [UIApplication sharedApplication];
// 打开appstore
if ([navigationAction.request.URL.absoluteString containsString:@"itunes.apple.com"]) {
if ([app canOpenURL:url]) {
[app openURL:url];
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
}
//下载企业包
if ([navigationAction.request.URL.absoluteString containsString:@"itms-services://"]) {
if (@available(iOS 10.0, *)) {
[app openURL:url options:@{} completionHandler:^(BOOL success) {
}];
} else {
[app openURL:url];
}
decisionHandler(WKNavigationActionPolicyCancel);
return;
}
decisionHandler(WKNavigationActionPolicyAllow);
endif
}