Amanpreet
Amanpreet

Reputation: 1321

Geo Fencing functionality iOS 11

I am working on Geo fence with Google map. My question is about the minimum radius for CLCircularRegion. As I want to work with the region for 30 meters. But the functionality works for the 100 meters. I have searched a lot and found that Apple needs minimum radius 100 to create a region, no matter I have set 30 meters or 50 meters.

Here is the link - Geofencing iOS 6

Moreover, didEnterRegion call at 100 meters and didExitRegion works very oddly and took much time. I have also read, that it depends upon tower cells etc according to that these methods call.

Here is the link - What is the maximum and minimum radius that can be set for regions in iOS geofencing.

I want to know if I have set the region for 50 meters. Why it is not working as per required region radius. In fact, I observe that it is working for the radius 100 meters.

Here is the code:

 func createRegion(lat : CLLocationDegrees,lng : CLLocationDegrees) -> CLCircularRegion?
    {
        let latitude = lat 
        let longitude = lng 
        var radius = CLLocationDistance(50)

        if radius > locationManager.maximumRegionMonitoringDistance
        {
            radius = locationManager.maximumRegionMonitoringDistance
        }

        let region = CLCircularRegion(center: CLLocationCoordinate2DMake(latitude, longitude), radius: radius, identifier: "TEST")

        region.notifyOnEntry = true
        region.notifyOnExit = true

        return region
    }

Or also can anyone refer a good app that has Geo fence functionality. So that I can compare my app's accuracy with it.

Question: I have selected 50 meters radius and 'upon exit' notification should come. But I am getting a notification on/around 250 meters and some time more than this. Please help me out

Thanks!

Upvotes: 1

Views: 1533

Answers (2)

Henrik Koberg
Henrik Koberg

Reputation: 146

I think you can reverse engineer the minimum radius on your device by looking at the device logs in Console. For example, if I set a radius of less than 100m on my iPhone 8 with iOS 14.7, I get the following log statement:

Fence:Start Started monitoring fence myapp/<private> (<<private>,<private>>, radius 100.000, active tech <private>)...

So, 100m seems to be the minimum in my case.

Upvotes: 1

Emmanuel
Emmanuel

Reputation: 189

Take a look at Apple`s developer documentation:

Article Apple

Official Documentation

When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.

The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.

And remind that if the Wi-Fi is disabled, then it will be less accurate.

Upvotes: 3

Related Questions