NSURLSession:handleEventsForBackgroundURLSession方法未在后台会话中运行 [英] NSURLSession: handleEventsForBackgroundURLSession method doesn't run in Background session

查看:341
本文介绍了NSURLSession:handleEventsForBackgroundURLSession方法未在后台会话中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

application:handleEventsForBackgroundURLSession:completionHandler:不运行.当所有上传/下载任务在后台完成时,iOS应唤醒该应用程序并调用上述方法.但事实并非如此.

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. 我已经通过从"xcode stop"按钮终止应用程序并从异常终止了这一点进行了测试.
  2. 我已遵循 Apple开发人员指南:背景示例中对此进行了测试,它不起作用.
  3. 我也在 AppCoda:背景示例上进行了测试,它是不起作用
  4. 在2点和3点中给出的两个示例在iOS 9.0和xCode 7.0上均不起作用.在升级到iOS9.0之前,我已经在可以完美运行的iOS7.0和xcode 5.0上对此进行了测试.
  5. 我假设它可以在真实设备上运行.
  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.

我在这里想念什么?有人可以确认handleEventsForBackgroundURLSession在iOS9.0模拟器中是否起作用,还是我做错了什么?由于它不适用于2和3中给出的示例,因此我想也许我正在测试错误.

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.

推荐答案

@ZayinKrige在评论中回答了这个问题:

@ZayinKrige answered this in a comment:

后台下载事件不会在模拟器上触发.您只能在真实设备上进行测试

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

还有一点扩展,这是测试后台会话代码的指南: https://forums.developer.apple.com/message/42353#42353

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

这篇关于NSURLSession:handleEventsForBackgroundURLSession方法未在后台会话中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆