WKWebView iOS 10.3 didReceiveAuthenticationChallenge 崩溃?
WKWebView iOS 10.3 crash for didReceiveAuthenticationChallenge?
func webView(webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
var user: String?
var password: String?
switch providerID {
case "197": // ABC Stagging
user = "ABC"
password = "abc"
default:
break
}
if let user = user, password = password {
let credential = NSURLCredential(user: user, password: password, persistence: NSURLCredentialPersistence.ForSession)
challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential, credential)
}
}
根据 crashlytics 的信息,崩溃正在在线发生 挑战不是由接收方发送的。
challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
感谢任何帮助。这仅发生在 iOS 10.3 上。我猜有些用户有测试版并且正在体验这个。
我也遇到同样的问题,我通过评论这一行解决了它
// challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
func webView(webView: WKWebView, didReceiveAuthenticationChallenge challenge: NSURLAuthenticationChallenge, completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
var user: String?
var password: String?
switch providerID {
case "197": // ABC Stagging
user = "ABC"
password = "abc"
default:
break
}
if let user = user, password = password {
let credential = NSURLCredential(user: user, password: password, persistence: NSURLCredentialPersistence.ForSession)
challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential, credential)
}
}
根据 crashlytics 的信息,崩溃正在在线发生 挑战不是由接收方发送的。
challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)
感谢任何帮助。这仅发生在 iOS 10.3 上。我猜有些用户有测试版并且正在体验这个。
我也遇到同样的问题,我通过评论这一行解决了它
// challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)