KMM iOS HttpClient NSURLSessionAuthChallengeDisposition 类型错误问题
我对 KMM 还很陌生,需要有关 httpClient 的帮助来忽略 ssl 证书。 使请求能够忽略 ssl 证书
HTTPClient(Android){
engine{
sslManager = {
httpsURLConnection ->
httpsURLConnection.hostnameVerifier = HostnameVerifier { _, _ -> true }
httpsURLConnection.sslSocketFactory = sslContext.socketFactory
}
}
}
我通过将以下代码添加到 HTTPClient Android Engine:和 iOS Engine: 上,
HTTPClient(Ios){
engine{
handleChallenge { session, task, challenge, completionHandler ->
completionHandler(NSURLSessionAuthChallengeUseCredential, null)
}
}
}
:但是,我在 iOS 端遇到了问题。 NSURLSessionAuthChallengeUseCredential 尽管继承自 NSURLSessionAuthChallengeDisposition 是一种 Kotlin.Long,但完成处理程序的第一个参数仅采用 NSURLSessionAuthChallengeDisposition,它是一种 platform.darwin.NSInteger 类型。
起初,我想将 NSURLSessionAuthChallengeUseCredential 转换为 Int 或 platform.darwin.NSInteger。它没有在 android studio 中触发任何错误,但是一旦我从 xcode 构建它,就会弹出以下错误:
类型不匹配:推断类型是 Int,但是 NSURLSessionAuthChallengeDisposition /* = Long */ 是预期的
我认为这是一个错误,因为 xcode 期望 NSURLSessionAuthChallengeDisposition 为 long 值,而 kmm 接受 platform.darwin.NSInteger 类型。
I am still new to KMM and need help on httpClient to ignore ssl certificate. I had made the request able to ignore ssl certificate by adding the following code to HTTPClient Android Engine:
HTTPClient(Android){
engine{
sslManager = {
httpsURLConnection ->
httpsURLConnection.hostnameVerifier = HostnameVerifier { _, _ -> true }
httpsURLConnection.sslSocketFactory = sslContext.socketFactory
}
}
}
and on iOS Engine:
HTTPClient(Ios){
engine{
handleChallenge { session, task, challenge, completionHandler ->
completionHandler(NSURLSessionAuthChallengeUseCredential, null)
}
}
}
However, I have an issue on iOS side. NSURLSessionAuthChallengeUseCredential despite inheriting from NSURLSessionAuthChallengeDisposition is a type of Kotlin.Long, but the completion handler’s first param only take NSURLSessionAuthChallengeDisposition which is a type of platform.darwin.NSInteger.
At first, i thought to just convert NSURLSessionAuthChallengeUseCredential to Int or platform.darwin.NSInteger. It didn’t triggered any error at android studio, but once i build it from xcode the following error pops up:
Type mismatch: inferred type is Int but
NSURLSessionAuthChallengeDisposition /* = Long */ was expected
I think this is a bug because the xcode expect NSURLSessionAuthChallengeDisposition to be a long value, while kmm accept type of platform.darwin.NSInteger.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论