我们有一个依赖于服务器网络调用的应用程序。
在某些情况下(我无法复制),当应用程序从后台进入前台时,在应用程序进入后台超时之前正在进行的网络调用。这是唯一一次网络呼叫失败的机会。
有人知道为什么会这样吗?
Alamofire配置+请求:
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 7 // seconds
AFManager = Alamofire.SessionManager(configuration: configuration)
AFManager.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).validate().responseString { response in
if response.result.isSuccess {
print(response)
completion()
} else {
print(response.error!)
completion()
}
}