WKWebKitView质询 - 响应身份验证完成处理程序未被调用

时间:2018-06-13 07:45:40

标签: ios objective-c

我目前正在Objective-C中使用WKWebKitView实现挑战 - 响应身份验证。 我实现了以下didReceiveAuthenticationChallenge:

-(void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler {
[[challenge sender] useCredential:[NSURLCredential credentialWithUser:@"app@email.com" password: @"******"  persistence:NSURLCredentialPersistenceNone] forAuthenticationChallenge:challenge];}

我已经像这样实现了WebView:

NSURLRequest *request = [NSURLRequest requestWithURL:requestURL];
        _wkView = [[WKWebView alloc] initWithFrame:self.view.frame];
        _wkView.frame = CGRectMake(self.view.frame.origin.x,self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
        [_wkView loadRequest:request];
        [self.view addSubview:_wkView];
        _wkView.navigationDelegate = self;

但是当调用URL时,应用程序崩溃并出现以下错误:

由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'传递完成处理程序 - [ReportViewerViewController webView:didReceiveAuthenticationChallenge:completionHandler:]未被调用'

0 个答案:

没有答案