WKWebView微信H5支付调用失败

如果你这么写

- (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);}


你可能感兴趣的:(WKWebView微信H5支付调用失败)