Is there a way to prevent CLLocationManager from persisting monitored regions between launches? Every time the app is launched I need to add a new set of monitored regions and the old ones are no longer useful. Is there a way to either prevent them from persisting or clear all of the old ones at launch time?
Of course you can clear all the regions currently monitored:
+(void)clearRegionWatch
{
for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
[[WGLocation shared].locationManager stopMonitoringForRegion:region];
}
}
If you had a specific identifier that you wanted to remove:
+(void)clearRegionWatchForKey:(NSString *)key
{
for(CLRegion *region in [[WGLocation shared].locationManager monitoredRegions]){
if([region.identifier isEqualToString:key]){
[[WGLocation shared].locationManager stopMonitoringForRegion:region];
}
}
}
You can copy the internals of the function into an appropriate place in your application. I've copied them from my shared manager class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With