Forum Discussion

bughunter's avatar
bughunter
Explorer | Level 3
8 years ago

Objective-C Api handle connection loss

Hi!

 

For our iOS Apps we are switching from the old Dropbox Api to the new Objective-C Api. In one app we use only the download function with dropbox. To achieve this, we implement

 

 

DBUserClient *client = [DBClientsManager authorizedClient];
DBDownloadDataTask *task = (DBDownloadDataTask* ) [client.filesRoutes downloadUrl:path overwrite: true destination: destinationUrl];
[task setResponseBlock:(^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *networkError, NSData *fileData) {
   // ....
})];
[task setProgressBlock:(^(int64_t bytesDownloaded, int64_t totalBytesDownloaded, int64_t totalBytesExpectedToDownload) {
   // ...
})];

Everything works fine, but now we want to handle connection losses, such as sudden Wi-Fi disconnections or 100% network loss with Network Link Conditioner. We don't know how to handle connection losses. The only reaction by the framework is:

 

NSURLConnection finished with error - code -1001
Task <96CC094A-A747-44D4-A6A5-1B016F07AE06>.<0> HTTP load failed (error code: -999 [1:89])

 

The framework waits, until a working connection is available. But nothing will be triggered, we can't save the files which are not downloaded successfully. I wish to set a timeout somewhere. We have always the scenario that we must sync a huge amount of data, so we only want to download the files which are not downloaded successfully...

 

Can someone help? Greetings!

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,941 PostsLatest Activity: 20 hours ago
351 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!