4

I kick off several NSURLSessionUploadTasks in a background NSURLSession. I want to know for sure whether all tasks keep their original taskIdentifier after I reconnect to this session in -application:handleEventsForBackgroundURLSession:completionHandler:, because I need to know which task is for which request and taskIdentifier is the only information I can use. I can not use URL to differentiate these POST requests because they are targeted to the same URL.

an0
  • 17,191
  • 12
  • 86
  • 136
  • 2
    What does the [documentation](https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSURLSessionTask_class/index.html#//apple_ref/occ/instp/NSURLSessionTask/taskIdentifier) tell you? What does experimentation tell you? – matt Dec 24 '14 at 15:42
  • 2
    @matt the doc does not say anything about the situation after session reconnection. I'm doing experiments but I want to know for sure because I'm using it in a real app and I don't want to make it work now only based on my own experiment results. If it is not the specified behavior I can not reliably use it. – an0 Dec 24 '14 at 15:48
  • The only "for sure" in this world _is_ the docs. They are the public official specification. What you know you know. Anything else will be anecdote. The docs do not mention reconnection, but they do guarantee uniqueness and persistence within the same session. This is the same session so I don't see what else you can ask for. – matt Dec 24 '14 at 16:05
  • @matt I hope you are right. But we all know the state of Apple docs. I also hope some  engineers could give an authoritative answer. I know after WWDC this year they are more active here. I'll also try dev forum. Thanks. – an0 Dec 24 '14 at 16:10

1 Answers1

3

From the results of my own experiments, I can confirm that NSURLSessionTask keeps taskIdentifier after session reconnection.

an0
  • 17,191
  • 12
  • 86
  • 136