Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get resumeData at UIApplicationWillTerminateNotification in NSURLSessionDownloadTask

I want to save data unfinished downloads when the app is closed.

Tried so, but always empty resumeData:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate) name:UIApplicationWillTerminateNotification object:nil];

- (void)appWillTerminate
{
    [self.downloadTask cancelByProducingResumeData:^(NSData *resumeData) {
        if (resumeData)
            [self saveData:resumeData];
        else
            NSLog(@"Not exist");
    }];
}
like image 740
nullproduction Avatar asked Nov 12 '22 17:11

nullproduction


1 Answers

In my experience, downloading small files does not create resumeData. Try with a larger file (> 20 mb).

like image 175
tobiasdm Avatar answered Nov 15 '22 07:11

tobiasdm