gpt4 book ai didi

ios - iOS 后台模式下的 GPS 监控

转载 作者:行者123 更新时间:2023-11-29 02:43:39 25 4
gpt4 key购买 nike

我想在 iOS 上实现一个功能,当到达特殊位置时通知用户(例如公交车站,不要错过),如果用户始终将应用程序置于前台模式,使用 GPS 位置检测,这很容易是否即将到达。关键是如何在后台模式下实现。

一种可能的解决方案是在后台模式下更新 GPS,例如 map 导航 APP,但正如您所知,GPS 是功率 killer ,用户可能不喜欢它。

查看CoreLocation API,发现以下委托(delegate)回调,我不确定它们在后台模式下是否运行良好。关于这个话题的任何想法请一起分享和讨论,并提前致谢。

- (void)locationManager:(CLLocationManager *)manager
didEnterRegion:(CLRegion *)region __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0);


- (void)locationManager:(CLLocationManager *)manager
didStartMonitoringForRegion:(CLRegion *)region __OSX_AVAILABLE_STARTING(__MAC_TBD,__IPHONE_5_0);

最佳答案

来自Location and Maps Programming Guide

In iOS, regions associated with your app are tracked at all times, including when the app isn’t running. If a region boundary is crossed while an app isn’t running, that app is relaunched into the background to handle the event. Similarly, if the app is suspended when the event occurs, it’s woken up and given a short amount of time (around 10 seconds) to handle the event. When necessary, an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler: method of the UIApplication class.

关于ios - iOS 后台模式下的 GPS 监控,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25416881/

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