Search code examples
iosios7ios8dropbox-apibackground-task

How can I download for longer than three minutes with Dropbox?


I'm at a point with my app where i'm able to download files, but there is a problem where if the download is >4 minutes, it times out. I've managed to boil it down to the it being 1 min for iPad auto lock, 3 for the background task.

I'm using the method:

[restClient loadFile:filePath intoPath:localPath];

I'm not sure if this is an Dropbox SDK issue or an iOS issue. I was under the impression you can download in the background for a long time, regardless of background task but for some reason the dropbox SDK stops.

My natural instincts would tell me to ask if there any way to extend the background task? I've read a lot of stuff online that says you can if it meets any of these requirements you can do stuff with the plist: https://stackoverflow.com/a/9738707/4056064 but my app doesn't fall under any of them categories.

I also read that you can use timers inside the BG task, but sadly then read that it doesn't work anymore.

The reason is that i'm trying to download quite large files to the app (sometimes 300mb), and people tend to walk away from their iPad.

edit- when I refer to background task, I meant beginBackgroundTaskWithExpirationHandler

Thanks


Solution

  • Background tasks are, as you found out, severely restricted. A different way of solving this problem is by disabling the automatic lock of the ipad as soon as the download starts:

      [UIApplication sharedApplication].idleTimerDisabled = YES;
    

    Don't forget to re-enable the timers when download is complete to avoid excessive power usage.