I have a requirement where user can download multiple files one after other. When my app goes in background OR when iPad is locked, the download or web-service response can be get only for 10 minutes.
My download happens in a separate thread, I have implemented beginBackgroundTaskWithExpirationHandler:
after some googling and on stackoverflow links.
How to implement Task completion
App crash because of auto lock in iphone?
and iOS documetation
Now some of my selected files are downloaded and some failed because one can run background task only for 10 min max.
Is there any alternative for this?? Should I pause download completely while app goes in background?? Can anyone help me regarding this??
I have succeeded to do so by not ending background task if my download is in progress
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"\n beginBackgroundTaskWithExpirationHandler called \n");
if(![self checkIfDownloadInProgress]){
[self endTaskOnCompletion];
}
}];
This works only if device is manually locked by user. If device locks automatically after 2 min, app runs for 10 min and then it is crashed Can anybody help?