gpt4 book ai didi

ios - 在 iOS 中实现长时间运行的后台任务

转载 作者:行者123 更新时间:2023-11-29 10:59:16 32 4
gpt4 key购买 nike

我的客户让我开发一些应用程序,定期检索用户位置和手机电池状态,然后将它们发送到我们的后端服务器进行数据分析,然后通过推送通知反馈。

但是通过应用文档,我从 apple ios dev 了解到 doc :

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

Apps that play audible content to the user while in the background,such as a music player app

Apps that keep users informed of theirlocation at all times, such as a navigation app

Apps that supportVoice over Internet Protocol (VoIP)

Newsstand apps that need todownload and process new content

Apps that receive regular updatesfrom external accessories

我想知道如果我们将这个应用程序包装成一些导航应用程序这样我们可以有长时间运行的后台任务,这是否可行?应用商店会拒绝我们的应用吗?

顺便说一句,Apple 对导航应用程序的定义是什么?

最佳答案

您可以考虑使用:

[CLLocationManager startMonitoringSignificantLocationChanges];

如果您的应用程序在位置显着变化时被终止,这将导致您的应用程序重新启动,从而允许您以相当定期的时间间隔更新服务器上的详细信息,假设用户正在移动。这不需要任何特殊的后台许可。来自文档:

If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the locationManager:didUpdateLocations: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event.

您的另一个选择是将应用配置为需要在后台持续更新位置,但在不知道应用的主要功能的情况下,很难知道这是否会通过商店提交。

关于ios - 在 iOS 中实现长时间运行的后台任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16747267/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com