NSURLSession: handleEventsForBackgroundURLSession

2020-07-27 02:11发布

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.

1条回答
Summer. ? 凉城
2楼-- · 2020-07-27 02:31

@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

查看更多
登录 后发表回答