Post

Replies

Boosts

Views

Activity

Reply to NSURLSessionDownloadDelegate methods not called after app resume
As hacky as this is, I found that briefly suspending and resuming the download task gets progress events firing again. I do this in response to UIApplicationDidBecomeActiveNotification. I'm not sure if all the thread dispatching is necessary but it gets the job done. [self.sharedBackgroundSession getAllTasksWithCompletionHandler:^(NSArray<__kindof NSURLSessionTask *> * _Nonnull tasks) { for (NSURLSessionTask *sessionTask in tasks) { if (sessionTask.state == NSURLSessionTaskStateRunning) { dispatch_async(dispatch_get_main_queue(), ^{ [sessionTask suspend]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [sessionTask resume]; }); }); } } }];Tested on physical devices running iOS 12.4.6 and 13.4.
Apr ’20