I wanted upload photos as background task but background execution stops automatically after 3 minutes.
Code which I have done:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
//Stop upload call
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
}}
I found that iOS puts strict limits on how long you can run. Specifically:
When you move from the foreground to the background, the limit is currently 3 minutes. When you are resumed in the background, the limit is 30 seconds.
Link referral : https://krumelur.me/2015/11/25/ios-background-transfer-what-about-uploads/
Thanks @feroz for providing the link.