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

标签 iphone ios location monitor region

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

根据位置感知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/

相关文章:

iphone - 委托(delegate)IBA行动

javascript - 如何防止 iPhone 用户上传多张图片

iOS URI 链接到 App Store 中的应用程序 (itms-apps)

Android Marshmallow Location 权限处理

iphone - iOS 下的 ZXing 不能在模拟器中运行

javascript - 如果 Web 服务器可以,为什么还要编写应用程序?

ios - NSString的initWithData和initWithBytes之间的区别

javascript - 滚动错误仅出现在 iPad 上

swift - 反向地理编码位置 : more accuracy than range

java - Android 位置监听器未触发