NSURLSession: handleEventsForBackgroundURLSession method doesn't run in Background session

雨燕双飞 提交于 2019-12-21 21:16:45

问题


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:


@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



来源:https://stackoverflow.com/questions/36071178/nsurlsession-handleeventsforbackgroundurlsession-method-doesnt-run-in-backgrou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!