美文网首页
WKWebView设置支持https

WKWebView设置支持https

作者: 丸_子 | 来源:发表于2017-01-24 15:50 被阅读63次

    要实现下面代理方法,当然别忘了设置代理navigationDelegate

    /**
     * 加这个方法https 支持
     **/
    - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler{
        if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
            NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];
            completionHandler(NSURLSessionAuthChallengeUseCredential,card);
        }
    }
    

    相关文章

      网友评论

          本文标题:WKWebView设置支持https

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