- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString* reqUrl = request.URL.absoluteString;
if([reqUrlhasPrefix:@"alipays://"] || [reqUrlhasPrefix:@"alipay://"]) {
BOOL bSucc = [[UIApplication sharedApplication]openURL:[NSURL URLWithString:reqUrl]];
//bSucc是否成功调起支付宝
if(!bSucc) {
[UtilityshowTipsWithHUD:@"请先安装支付宝"showTime:2];
}
}elseif([reqUrlhasPrefix:@"weixin://"]) {
BOOL bSucc = [[UIApplication sharedApplication]openURL:[NSURL URLWithString:reqUrl]];
//bSucc是否成功调起微信
if(!bSucc) {
[UtilityshowTipsWithHUD:@"请先安装微信"showTime:2];
}
}
return YES;
}
WKWebView 对应的方法为
- (void)webView:(WKWebView*)webViewdecidePolicyForNavigationAction:(WKNavigationAction*)navigationActiondecisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler
{
NSLog(@"navigationAction.request.URL--%@", navigationAction.request.URL);
decisionHandler(WKNavigationActionPolicyAllow);
}