I have an iOS app that provides multiple book download at the same time, Its a reader app actually. Earlier I was using AFDownloadRequestOperation for download the book. When user launch the app after app crashes or after user force quit (kill) the app, It automatically resume the download from the offset where it left downloading and for this to achieve I was using the following method:
AFDownloadRequestOperation* operation = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:path shouldResume:YES];
Now I am using AFNetworking 2.0 API AFHTTPSessionManager for background download. I have created the background session in the following way:
NSString* strIdentifier = [NSString stringWithFormat:@"someUniqueIdentifier"];
NSURLSessionConfiguration *sessionConfig;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >=8.0f)
{
sessionConfig =[NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:strIdentifier];
}
else
{
sessionConfig = [NSURLSessionConfiguration backgroundSessionConfiguration:strIdentifier];
}
self.backgroundSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:sessionConfig];
Then I have started the background download task as follows with delegate callbacks:
self.bookDownloadTask = [self.backgroundSessionManager downloadTaskWithRequest:request progress:nil destination:nil completionHandler:nil];
[self.bookDownloadTask resume];
So again considering the earlier situation -
When user launch the app after app crashes or after user force quit (kill) the app, It does automatically start (not resume) the download but not from the offset where it left downloading, it start downloading form starting of the book.
Is there any way to automatically resume the download from the offset where it left downloading using AFHTTPSessionManager ??
Any help would be appreciated. Thanks !!