I am downloading 500 files serially (One by One) Each file is around 4-5 MB size. I have created NSURLSession
with backgroundSessionConfigurationWithIdentifier
because, my files may download when the app in background mode also.
- (NSURLSession *)backgroundSession
{
static NSURLSession *session = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:bundleIdentifier];
configuration.HTTPMaximumConnectionsPerHost = 1;
configuration.sharedContainerIdentifier = bundleIdentifier;
session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
});
return session;
}
And, i am using NSURLSessionDownloadTask
to download the files and once a file downloaded, i am starting a next download on didFinishDownloadingToURL
delegate method. And, i have these below lines on my app delegate too.
AppDelegate.h
@property (copy) void(^backgroundSessionCompletionHandler)();
AppDelegate.m
-(void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler{
self.backgroundSessionCompletionHandler = completionHandler;
}
Here's my question. Once my app goes into background, will my app successfully continue this download process. Have i given all the settings needed for non interrupted download Or i need to enable any other settings more?
Kindly, guide me.