我最近正在制作一个应用程序,当我提出Internet请求时,一切都很好。但是当我提交“ App Store评论”时,他们拒绝了我,说该应用程序无法访问服务器。 Crashlytics说它是错误代码-1005。
我已经搜索了一个星期左右,没有任何事情可以解决我的问题。我尝试关闭HTTP Keep-alive,但是它什么也没做,并且在我所有的设备上都没有遇到任何错误。服务器没有做错任何事情,即使它是In Review.
这是我的示例代码。希望有人能帮助我。
Alamofire.request(requestURL).responseString{ response in
if response.error != nil {
self.indicatorBackView.isHidden = true
self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents()
Crashlytics.sharedInstance().recordError(response.error!)
let errorAlert = UIAlertController(title: "Error", message: "Unknown error, please check the internet connection or contact the developer.", preferredStyle: .alert)
errorAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(errorAlert, animated: true, completion: nil)
}else{
let decoder = JSONDecoder()
print(String(data: response.data!, encoding: .utf8)!)
do{
currentVersion = try decoder.decode(appVersion.self, from: response.data!)
if !(currentVersion.ios!.contains(versionNumber)){
let alert = UIAlertController(title: "Detected Newer Version.", message: "Please update the app to the newest version on the App Store!", preferredStyle: .alert)
let action = UIAlertAction(title: "OK(Redirects to the App Store)", style: .default, handler: {
(action: UIAlertAction!) -> () in
UIApplication.shared.openURL(itmsURL)
})
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
}catch let error{
print(error)
let alert = UIAlertController(title: "Oops", message: "Unknown error occured. Pleast contact the developer.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
Crashlytics.sharedInstance().recordError(error)
self.present(alert,animated: true, completion: nil)
}
self.indicatorBackView.isHidden = true
self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents()
}
}
我正在使用Alamofire 4.8.1。