1

I am using below code to create background session for huge uploads,

NSURLSessionConfiguration *config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:identifier];

NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:delegate delegateQueue:nil];

and save the identifier to re-associate with the session later. But once app goes to background and terminated by OS then, upon relaunch I am not receiving any callbacks from that session even if I use same identifier to create session. It always creates new session that has no ongoing upload task.

The previous task can't finish this early as I have GBs to upload.

Am I missing anything here ? any additional setting etc.

nmhmd
  • 11
  • 4
  • How are you determining that the task successfully started and that it wasn't still going after the app resumed? – Marcus Adams May 19 '15 at 13:53
  • @MarcusAdams after starting the upload, i was getting upload progress before app went into the background. When resumed, if app was only suspended, then it continues giving me progress. But if app was terminated by OS and relaunched then there are no callbacks from session. – nmhmd May 20 '15 at 06:49

1 Answers1

0

Save the delegate as well in order to receive the call backs! The instance of the delegate is not retained after the App kill.

Make your delegate comply to NSCoding protocol and do the archiving and unarchiving!

Cheers:)

Kaushil Ruparelia
  • 1,179
  • 2
  • 9
  • 26
  • It really matters to retain the delegate ?? because when we are create the session object again with the same identifier then we can assign it a new delegate and it should start sending callbacks to that delegate. – nmhmd May 21 '15 at 07:58
  • BUt your task is created in this session. So when you create a new session your previously ongoing task wont be associated with the new session unless and until you create a new task in this session – Kaushil Ruparelia May 21 '15 at 08:55