I am trying to load image from URL on the iphone, image is there and I can open it in safari with same link, but not in the app:
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname
could not be found." UserInfo={NSUnderlyingError=0x17024f810
{Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)"
UserInfo={_kCFStreamErrorCodeKey=50331647, _kCFStreamErrorDomainKey=6147928288}},
NSErrorFailingURLStringKey=https://........, NSErrorFailingURLKey=https://.........
Code of request:
func downloadImage(userEmail: String, onCompletion: @escaping (UIImage) -> Void) {
print("Download Started")
let route = "\(baseURL as String)\(userEmail as String)\(baseURLparameters as String)"
let url = URL(string: route)
getDataFromUrl(url: url!) { (data, response, error) in
guard let data = data, error == nil else {
print("===failed:", error ?? "dunno")
print("===url:", url?.absoluteString ?? "dunno")
return
}
print(response?.suggestedFilename ?? url!.lastPathComponent )
print("Download Finished")
DispatchQueue.main.async() { () -> Void in
onCompletion(UIImage(data: data)!)
}
}
}