Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLSession: handleEventsForBackgroundURLSession method doesn't run in Background session

application:handleEventsForBackgroundURLSession:completionHandler: doesn't run when the uploads are finished in the background. When all the upload/download tasks are completed in the background then iOS should wake up the app and call the above method. But it doesn't.

  1. I have tested this by terminating the app from 'xcode stop' button and also terminated from an exception.
  2. I have followed Background Transfer consideration.
  3. I have tested this on Apple developer guide: Background example and it is not working.
  4. I have also tested this on AppCoda: Background example and it is not working
  5. Both of the examples which are given in 2 and 3 points are not working on iOS 9.0 and xCode 7.0. Before upgrading to iOS9.0, I had tested this on iOS7.0 and xcode 5.0 where it ran perfectly.
  6. I am assuming that it would work on the real device.

What am I missing here? Can anybody confirm whether handleEventsForBackgroundURLSession works in iOS9.0 simulator or am I doing anything wrong? Since it doesn't work for the examples given in 2 and 3 so I guess maybe I am testing it wrong.

like image 902
Utsav Dusad Avatar asked May 11 '26 07:05

Utsav Dusad


1 Answers

@ZayinKrige answered this in a comment:

background download events don't fire on a simulator. You can only test this on a real device

And to expand a bit, here's a guide for testing background session code: https://forums.developer.apple.com/message/42353#42353

like image 151
Crag Avatar answered May 12 '26 23:05

Crag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!