I have requirement to download files in serial order. Currently I am able to do that while app is in foreground.
Following is the logic I have used.
Create all tasks for downloading.
Resume one at a time and as the current finishes resume the next one from
URLSession:task:didCompleteWithError:
.
This logic is working while app is in foreground but once app started to run in background(By crashing) and we again run the app before download finishes all the tasks state has been changed to resume and all are downloading at the same time.
Is this the expected behaviour or anything I am missing to order this in serial in background mode too?
Edit:
I checked by creating download task one by one. After finishing the first task create next inside setTaskDidCompleteBlock
and so on. It only completes the first task and after that session crashed while task created inside setTaskDidCompleteBlock
(This happens only when running in background mode, for foreground its working fine).
Here is my crash log screen shots:
and
Any help would be appreciated.