I am working on such a project where apps do the following things:
viewController
by pressing "Go" buttonNow, Here I monitor one region, after that another one. So the number is actually one. But I know the maximum number of regions one apps can monitored by "Region Monitoring" is 15. Now my question is in this case should I handle this maximum number of region issue or not? If yes, then how?
One more thing I want to add is, there are some solution of it, which is only work for iOS 6 and earlier. So please let me know if there have some solution of handling number of "region" monitored by "RegionMonitoring", based on users current location in iOS7.
It will be a great pleasure to me if one can give the answer or any suggestion to finish my apps required requirements.
Overview. Region monitoring (also known as geofencing) is a way for your app to be alerted when the user enters or exits a geographical region. You might use region monitoring to perform location-related tasks.
Core Location provides services that determine a device's geographic location, altitude, and orientation, or its position relative to a nearby iBeacon device. The framework gathers data using all available components on the device, including the Wi-Fi, GPS, Bluetooth, magnetometer, barometer, and cellular hardware.
Use CoreLocation to fetch Location. CoreLocation is a framework that is used to obtain the geographic location and orientation of a device.
If you check the docs, max limit is 20. When you exceed this number, the iOS
will release monitoring of the oldest region (think its like its a FIFO queue). Make sure you keep the radius smaller than maximumRegionMonitoringDistance
. So in other words you don't need to worry about max limit, you can make sure this by implementing didStartMonitoringForRegion:
delegate.
But, If you want to control number of regions being monitored by yourself, you can always stop monitoring a region using stopMonitoringForRegion:
You can get a list of regions being monitored with the property monitoredRegions
. You can always clear up the region you don't need any more. It's a good practice to keep it minimum as it does effect the battery and app performance.
I'm using following code to clear up all my regions when required.
for (CLCircularRegion *region in self.locationManager.monitoredRegions) {
[self.locationManager stopMonitoringForRegion:region];
}
But in your case, I would suggest using a constant for Region identifier (e.g. "MY-REGION"), as you cannot monitor two regions with same identifier, adding an other region with the same id removes previously monitored region automatically.
CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:coordinate radius:50.0f identifier:@"MY-REGION"];
[self.locationManager startMonitoringForRegion:region];
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