WKWebView微信H5支付调用失败

2018-10-13  本文已影响114人  小福8090

如果你这么写

- (void)webView:(WKWebView*)webView decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler{if(navigationAction.navigationType ==WKNavigationTypeLinkActivated) {        [[UIApplicationsharedApplication] openURL:navigationAction.request.URL options:@{} completionHandler:^(BOOLsuccess) {        }];        decisionHandler(WKNavigationActionPolicyAllow);    }else{                decisionHandler(WKNavigationActionPolicyAllow);            }}

这么写可以调用支付宝,但是微信就会出现参数错误的网页提示。

解决如下,换种写法。如果帮到你,记得回来点赞哦!

- (void)webView:(WKWebView*)webView decidePolicyForNavigationAction:(WKNavigationAction*)navigationAction decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler{if([navigationAction.request.URL.absoluteString hasPrefix:@"weixin://"] || [navigationAction.request.URL.absoluteString hasPrefix:@"alipay://"]) {                [[UIApplicationsharedApplication] openURL:navigationAction.request.URL options:@{} completionHandler:^(BOOLsuccess) {                    }];            }        decisionHandler(WKNavigationActionPolicyAllow);}

上一篇下一篇

猜你喜欢

热点阅读