用户可能在使用App过程中可能会出现不能正常唤起支付宝的情况。

处理方式:请在webview中设置允许打开alipays或alipay协议。

示例代码:

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{

    NSString *url = [navigationAction.request.URL.absoluteString stringByRemovingPercentEncoding];

    //唤醒支付宝客户端支付
    if ([url containsString:@"alipay://"]) {
        [[UIApplication sharedApplication] openURL:navigationAction.request.URL];

        decisionHandler(WKNavigationActionPolicyAllow);

        return;

    }
    else{

        NSString *hostname = navigationAction.request.URL.host.lowercaseString;
        if (navigationAction.navigationType == WKNavigationTypeLinkActivated
            && ![hostname containsString:@".lanou.com"]) {
            [[UIApplication sharedApplication] openURL:navigationAction.request.URL];

            decisionHandler(WKNavigationActionPolicyCancel);
        } else {
            decisionHandler(WKNavigationActionPolicyAllow);
        }


    }
}

results matching ""

    No results matching ""