我毫无疑问,想知道是否有必要再次将所有区域重新分配给位置经理,如果它收到发布通知appEnterInBackGround
?
这是一些代码片段。
- (IBAction)startAction:(id)sender
{
for (Geofencing *gObjects in plotingArrays) {
CLCircularRegion *getRegion = [self dictToRegion:gObjects];
[monitorLocationManager startMonitoringForRegion:getRegion];
}
}
因此,当应用程序进入后台时,我确实是这样的:
# pragma mark - BackGround Notification
-(void)applicationEnterBackground
{
monitorLocationManager = [selectRouteController sharedLocationMonitor];
monitorLocationManager.delegate = self;
for (Geofencing *gObjects in plotingArrays) {
CLCircularRegion *getRegion = [self dictToRegion:gObjects];
[monitorLocationManager startMonitoringForRegion:getRegion];
}
}
那么当应用程序进入后台时,是否有必要再次将区域重新分配给位置管理器?或者,一旦将区域分配给位置管理器,它就会自动startAction:
监控
更新1:
+ (CLLocationManager *)sharedLocationMonitor {
static CLLocationManager *locationMonitor;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
locationMonitor = [[CLLocationManager alloc] init];
locationMonitor.desiredAccuracy =
kCLLocationAccuracyBestForNavigation;
locationMonitor.activityType =
CLActivityTypeAutomotiveNavigation;
[locationMonitor requestAlwaysAuthorization];
if(IS_OS_9_OR_LATER){
locationMonitor.allowsBackgroundLocationUpdates = YES;
}
if(SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(@"8.4")){
locationMonitor.pausesLocationUpdatesAutomatically = NO;
}
});
return locationMonitor;
}
列表: