gpt4 book ai didi

iphone - 后台模式下的iOS区域监控

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:17 29 4
gpt4 key购买 nike

我在我的应用程序中使用区域监控,我遇到了一个我找不到任何答案的问题。区域监控在后台模式下是如何工作的?

根据位置感知PG:

Every time the user’s current location crosses a boundary region, the system generates an appropriate region event for your application. If your application is already running, these events go directly to the delegates of any current location manager objects. If your application is not running, the system launches it in the background so that it can respond.

现在,这个问题是:我的应用程序处于挂起模式,已经进入一个区域并且应该传递一个触发器,这个事件是否将“直接”发送到代理的:

locationManager:didEnterRegion:

??如果应用程序处于后台模式,同样的问题。换句话说,在挂起和后台模式下是否应该考虑任何代码来接收此事件?或者iOS会先启动应用程序,然后直接将事件发送给委托(delegate)而不需要任何BG代码?

最佳答案

区域监控如果您在后台,当您进入监控区域时重新启动您的应用程序。

但是您必须在应用重新启动后再次配置您的位置管理器。

像这样的——

if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey] ) 
{

NSLog(@"Relaunched due to location update");

NSLog(@"app woke up times ---- %d",ForTest);

NSLog(@"Starting the location manager");
self.locmanager = [[CLLocationManager alloc] init];
[self.locmanager startMonitoringForRegion:(CLRegion)*region];
// self.locmanager.pausesLocationUpdatesAutomatically = YES ;
}

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

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