I have an application in which I have to upload large videos to Amazon s3 bucket. I am using NSOperations regulated by an NSOperationQueue to run concurrent tasks.
I don't have problems when upload small videos (smaller then 200 Mb). But the problem is when i try to upload a large video, after 10 minutess the upload process gets interrupted.
I'm already using beginBackgroundTaskWithExpirationHandler:^
to get a window of 10 mins. What is the proper way by which I can extend this timeout period?
Will Apple reject the app if I somehow manage to extend this timeout?
Presently I have the following code in my AppDelegate
which I built referring to the link iPhone - Backgrounding to poll for events
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication* app = [UIApplication sharedApplication];
dispatch_block_t expirationHandler;
expirationHandler = ^{
bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
};
bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
}
With this piece of code I see that the background task gets never interrupted. As you can see inside the expiration handler, I've initiated another background task event which leads to an infinitely running task. Even though, I can write the logic to end the background task once my upload is finished, but I'm having doubts about this approach..
What do you guys think?
Is it a hack by any means? Will Apple reject the app for following approach?