0

Working on an app that does background uploads, using NSURLSession

backgroundSessionConfigurationWithIdentifier

And getting the

handleEventsForBackgroundURLSession

call back in app delegate properly when the app is not in the foreground. My question is : Should I expect that to happen if the app is in the foreground ( ie : runnig)? The reason is based on that call I display a message to the user that uploads are done.

or should I have my own logic that once all tasks are finished and upload was successful?

Utsav Dusad
  • 2,139
  • 4
  • 31
  • 52
Huang
  • 1,355
  • 2
  • 11
  • 28
  • 1
    See this [issue](http://stackoverflow.com/questions/36071178/nsurlsession-handleeventsforbackgroundurlsession-method-doesnt-run-in-backgrou). Are you facing the same issues with the examples given in the above link? – Utsav Dusad Mar 17 '16 at 20:37
  • 1
    `handleEventsForBackgroundURLSession ` method doesn't get called on the foreground. In iOS, when a background transfer completes or requires credentials, if your app is no longer running, iOS automatically relaunches your app in the background and calls the above method on your app’s UIApplicationDelegate object. See: [Source](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/UsingNSURLSession.html#//apple_ref/doc/uid/TP40013509-SW44). – Utsav Dusad Mar 17 '16 at 20:44

1 Answers1

0

I think handleEventsForBackgroundURLSession will never happen, if the application is foreground. if you want to show a message to user on foreground, please use <NSURLSessionDelegate, NSURLSessionTaskDelegate>

dosuken123
  • 438
  • 3
  • 7
  • 19