0

I have a problem with my App based in Region Monitoring in iOS;

Suppose that I have a Monitored Region with 300 meters radius, and my location is 350 meters off the center of that region (but I am into a car moving get closer to my region).

If I close my App in that moment the GPS is turned Off instantly and the method "didEnterRegion" is never called. This problem doesn't happen if my location is farther to my region monitored (for example 500 meters away)

Is possible to fix this? I tried with "Background modes" setting the "Required location services" in background, but this make to use the GPS instead "Region Monitoring" and the GPS never stops.

The problem with Region Monitoring is that this function never works when the user is already "inside the region", then this causes a lot of problems for the in time notification.

1 Answers1

0

First, you don't need background mode for region monitoring to work, region monitoring will continue to function even if you Sleep your device(pressing the top button). Plus Apple can reject your app if you don't use BG mode according to how they need it.

For your issue, if you are already inside and you are not getting a didEnterRegion for whatever reasons, you should use a backup plan. In your CLRegion class you can call containsCoordinate to see if you are inside the region.

You did not get a didEnterRegion call probably for some reason your add region gets reinitialized. I.e. you have re-added your region.

mskw
  • 10,063
  • 9
  • 42
  • 64
  • Thanks for your answer, I didn't know of `containsCoordinate` function, but I use `distanceFromLocation` for the same goal, but this works only if I am inside the region, but for example if I am 1 meter outside the region then for the App "I am out", but if in that second I close the App, for that moment "I am inside the region now" but like I never crossed the bound, the notification is not fired – Roberto Briones Argüelles Apr 09 '13 at 18:31
  • Test carefully, it should fire even if you closed the app, the question is how did you capture if it is fired? – mskw Apr 09 '13 at 18:56
  • I put a lot of "NSLog's" in my App, when enter in "didEnterRegion", "didUpdateLocations", etc. The problem is not the App closing, when I am far away from my region and I close the App, there is no problem. But when I am just a few meters around and I am walking to my region and then I close my App, the Notification is not fired. – Roberto Briones Argüelles Apr 09 '13 at 21:27
  • Maybe is working correctly, if it is in the boundary, is not good to fire entry/exit continuously. It makes sense implement region entry/exit updates this way. have you tried to go all the way into the region to see if it triggered? – mskw Apr 09 '13 at 21:31