美文网首页
WKWebView微信H5支付调用失败

WKWebView微信H5支付调用失败

作者: 小福8090 | 来源:发表于2018-10-13 10:49 被阅读114次

    如果你这么写

    - (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支付调用失败

          本文链接:https://www.haomeiwen.com/subject/gxpiaftx.html