Hi Apple developers,
I am new to IOS development and have recently added to my app the ability to download a file from a web API I created to be used in the app. The strange thing is this works fine in the simulator but when I plug in my IOS device I get these two errors:
nw_endpoint_handler_set_adaptive_read_handler [C2 192.168.1.67:5000 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for read_timeout failed
and
nw_endpoint_handler_set_adaptive_write_handler [C2 192.168.1.67:5000 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for write_timeout failed
Other endpoints from the web API that do not involve file downloads still work on the device.
The file type is a usdz model
Here is the code used to download and store the file:
class ModelFetcher: NSObject{
var modelUrl: URL?
func generateModel() {
guard let url = URL(string: "http://192.168.1.67:5000/model.usdz") else {return}
let urlSession = URLSession(configuration: .default, delegate: self, delegateQueue: OperationQueue())
var request = URLRequest(url: url)
request.httpMethod = "POST"
let downloadTask = urlSession.downloadTask(with: request)
downloadTask.resume()
}
}
extension ModelFetcher: URLSessionDownloadDelegate {
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
print("File Downloaded Location- ", location)
let docsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let destinationPath = docsPath.appendingPathComponent("model.usdz")
try? FileManager.default.removeItem(at: destinationPath)
do {
try FileManager.default.copyItem(at: location, to: destinationPath)
self.modelUrl = destinationPath
print("File moved to: \(modelUrl!)")
} catch let error {
print("Copy Error: \(error.localizedDescription)")
}
}
}
Perhaps I have missed some configuration setting needed to allow file downloads on a device? Because, again, it works on the simulator but not on my own device, and, again, the other plain JSON endpoints still work on the device.
Any help would be much appreciated.
Thanks
Louis
If you implement the urlSession(_:task:didCompleteWithError:) delegate method, what do you see?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"