【问题标题】:WKWebView iOS 10.3 crash for didReceiveAuthenticationChallenge?didReceiveAuthenticationChallenge 的 WKWebView iOS 10.3 崩溃?
【发布时间】:2017-02-21 18:17:26
【问题描述】:
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 上发生。我猜有些用户有测试版并且正在经历这个。

【问题讨论】:

  • 有人解决了这个问题吗?我面临同样的问题。请帮忙

标签: ios iphone authentication wkwebview ios10.3


【解决方案1】:

对我来说同样的问题,我通过评论这一行来解决它

//    challenge.sender?.useCredential(credential, forAuthenticationChallenge: challenge)

【讨论】:

  • 是的,我也是这样做的。
  • 我们应该可以设置凭据
  • 通过评论您现在如何发送凭据??
  • 您可以通过将凭据添加到请求 URL 来发送凭据。例如login:password@your.page.com
  • 评论这一行并保持completionHandler(URLSession.AuthChallengeDisposition.useCredential, credential)为我修复它
猜你喜欢
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多