且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在iOS中运行后台服务

更新时间:2022-06-07 22:36:09

在您请求的时间间隔内无法永久执行后台任务。您可以通过开发者连接请求特定权限,但我必须警告您,您需要一个非常有说服力的论点。我包含了下面的文档,也许您的请求属于可以永久运行的分组之一。或者也许您可以使用其中一个长时间运行的后台线程并使其适应您正在尝试的任务。

There is no way to perform tasks in the background permanently at the interval of time you are requesting. You may request specific permission via the developer connection but I must warn you that you will need a very compelling argument. I included the documentation below, maybe your request falls within one of the groupings that could run permanently. Or maybe you could use one of the long running background threads and adapt it in such a way that it fulfils the task you are attempting.

直接来自Apple的文档:

Directly from Apple's Documentation:

对于需要更多执行时间来实现的任务,您必须请求特定权限在后台运行它们而不会被暂停。在iOS中,只允许特定应用类型在后台运行:

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:


  • 在后台播放用户可听内容的应用,
    ,例如音乐播放器应用

  • 让用户随时了解其
    位置的应用,例如导航应用支持
    语音的应用需要
    下载和处理新内容的互联网协议(VoIP)报亭应用程序

  • 从外部附件接收定期更新的应用程序

实施这些服务的应用程序必须声明它们支持的服务,并使用系统框架来实现这些服务的相关方面。声明服务可以让系统知道您使用哪些服务,但在某些情况下,系统框架实际上会阻止您的应用程序被暂停。

Apps that implement these services must declare the services they support and use system frameworks to implement the relevant aspects of those services. Declaring the services lets the system know which services you use, but in some cases it is the system frameworks that actually prevent your application from being suspended.

〜/ End of Line

~/End of Line