Detect if user enters or leaves a region - geocoding

I start with geocoding. And I have a lot of doubts.

I can do forward and reverse geocoding (I think this is not ideal).

And now I'm trying to determine if the user (device) is logging in or leaving the region. For this, I took a sample of the Regions apple code . In the example used regionMonitoring. I already tried this on the device, but it does not work well. I set up an area with a radius of 25 meters, and when I left the area (walking), nothing happens.

My question is: is there any other and better way to do this, to determine whether the user enters or leaves the region, than regionMonitoring?

Can someone help me here?

Many thanks.

0
source share
2 answers

I found a solution to calculate the distance between the two CLLocationCoordinate2D, it is easier than me:

- (CLLocationDistance) DistanceBetweenCoordinate:(CLLocationCoordinate2D)originCoordinate andCoordinate:(CLLocationCoordinate2D)destinationCoordinate {

    CLLocation *originLocation = [[CLLocation alloc] initWithLatitude:originCoordinate.latitude longitude:originCoordinate.longitude];
    CLLocation *destinationLocation = [[CLLocation alloc] initWithLatitude:destinationCoordinate.latitude longitude:destinationCoordinate.longitude];
    CLLocationDistance distance = [originLocation distanceFromLocation:destinationLocation];
    [originLocation release];
    [destinationLocation release];

    return distance;
}
0
source

you can keep track of the user's location in the background ( here is a good tutorial ), but keep in mind that it can be harder to use the battery than regionMonitoring.

0
source

All Articles