1

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.

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
  • Possible duplicate of [How to download files in background mode iOS? And Network connection Lost](http://stackoverflow.com/questions/38243333/how-to-download-files-in-background-mode-ios-and-network-connection-lost) – shallowThought Mar 03 '17 at 12:34

0 Answers0