gpt4 book ai didi

ios - 尽管用户已终止应用程序并检查 iOS 中的设备位置,如何保持 iOS 应用程序进程始终运行?

转载 作者:行者123 更新时间:2023-12-01 18:11:40 25 4
gpt4 key购买 nike

我需要每隔一小时左右检查一次设备位置,如果该位置在特定区域之外(例如设备已被带出办公场所),请执行一些操作(例如显示本地通知“嘿!设备在办公室外面”)。

为此,即使应用程序被终止,我也需要每隔一小时检查一次位置。如何让应用程序永远保持活力,尽管它已被用户终止。

最佳答案

是的,您可以这样做,但如果您的系统是部署目标,则大于 7.0。

在 ios7.1 中有一个方法叫做 startMonitoringSignificantLocationChanges .此方法在后台更新位置,即使应用程序根据苹果文档终止:

Starts the generation of updates based on significant location changes.

If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives. In such a case, the options dictionary passed to the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods of your app delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your app was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.



我为此找到了一个演示,可能会对您有所帮助。看这个链接 http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended

关于ios - 尽管用户已终止应用程序并检查 iOS 中的设备位置,如何保持 iOS 应用程序进程始终运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29763564/

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