iOS Region Monitoring in Background Mode

戏子无情 提交于 2019-12-03 11:33:24

Region monitoring Relaunches your application when you enter the monitored region if you are in background .

however you have to again configure your location manager after the app relaunches .

something like this -

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 ;
    }

As far as I know region monitoring only works with iPhone4 and it's based on the device changing the communication towers. This way it uses way less battery than the standard background location update. Make sure you enabled the appropriate background modes. As long as you implement that delegate, you should be ready to go.

enable Background Modes in that enable Location updates and Background Fetch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!