gpt4 book ai didi

iOS 8 didReceiveAuthenticationChallenge 没有被 WKWebView Objective C 调用

转载 作者:行者123 更新时间:2023-11-29 12:20:20 25 4
gpt4 key购买 nike

我是 iOS 开发新手。我有一个项目,我必须使用 WKWebView 而不是 UIWebView。它是一个简单的网页,带有 javascript 到 Objective-C 和其他集成方式。它工作正常,除非我尝试打开带有自签名证书的服务器。在 Safari 上,它会显示一个对话框,我们可以在其中选择继续。但是,在我的申请中,我无法绕过这一点。

出于某种原因,我必须使用自签名证书来运行它。

永远不会调用委托(delegate)方法 didReceiveAuthenticationChallenge。其他委托(delegate)方法工作正常。我知道 didReceiveAuthenticationChallenge 在 iOS8 中已贬值,但有人可以告诉我解决方法。由于我是新手,因此非常感谢完整的工作委托(delegate)方法和/或代码中的任何其他更改。

NSURL *url = [NSURL URLWithString:@"https://mywebsite.com/Default.aspx"];

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

[[self webView] loadRequest:request];

}

// And the delegate method that is not getting called is
- (void)webView:(WKWebView *)webView
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler {
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
CFDataRef exceptions = SecTrustCopyExceptions(serverTrust);
SecTrustSetExceptions(serverTrust, exceptions);
CFRelease(exceptions);

completionHandler(NSURLSessionAuthChallengeUseCredential,
[NSURLCredential credentialForTrust:serverTrust]);

最佳答案

这已被 Apple 确认为错误。它已在 iOS9 中修复。

关于iOS 8 didReceiveAuthenticationChallenge 没有被 WKWebView Objective C 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30827081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com