1

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

Community
  • 1
  • 1
Ben
  • 1,061
  • 10
  • 23

2 Answers2

0

Can you refer my Answer here : AVAudioPlayer is not playing in Background when iPhone is locked. Actually, my problem is can't able to write/read while downloading or listening media from the sandbox. That's why I used Data - Protection API. I think it's based on Security issue. After I applied these attributes, I fixed this issue. I can able to downloaded big size video also. No issue for me.

Community
  • 1
  • 1
iTag
  • 409
  • 3
  • 19
-1

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.

Aaganrmu
  • 328
  • 1
  • 11
  • Thanks, that's a great simple solution. Hopefully dropbox people may reply with something that actually solves a user locking it, but if not i'll accept this tomorrow :) – Ben Feb 12 '15 at 13:25
  • I would hate to find out my personally set phone settings have been altered just so a download service could do its job. Have you looked into https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/ specifically `beginBackgroundTaskWithName:expirationHandler:` ? – soulshined Feb 12 '15 at 15:03
  • This is also a bad solution because it doesn't fix user related tasks. What happens when the user receives a phone call, text message or FaceTime or resigns active in multitasking? You can't force a user to stay in the app @Ben – soulshined Feb 12 '15 at 15:13
  • Hi Soulshined. Yes, if you'd read the question, I mention background task a couple of times. Perhaps I should have included the code but regardless it has a 180 second limit sadly. You can't reinitialise it from inside its self either. So as it stands, his solution is the best one i've came across. Any other ideas? – Ben Feb 13 '15 at 13:11