I need to pause download tasks and resume it even after app restarted. But I am unsure which method should I use, suspend
or cancelByProducingResumeData
.
With cancelByProducingResumeData
I can get the partially downloaded data and recreate download task with it. However I have to manually manage the data, save it to file, read it back, and recreate the task and ensure the new task doesn't fail.
With suspend
, I can pause and resume the download task. But can I resume this task after the app is restarted? I am using background session so tasks are preserved across restart.
cancelByProducingResumeData
have requirements for it to work, does those requirements also applies to suspend
/resume
? Or suspend
/resume
is only mean for "temporarily suspends a task" as the document said?