nwales
nwales

Reputation: 3561

How to determine if user is already within region when CLLocationManager begins monitoring regions

I have an app that is ranging beacons in the background. When I initialize my CLLocationManager instance I'm starting things off with the startMonitoringForRegion method. I am handling the locationManager:didEnterRegion, locationManager:didExitRegion, and locationManager:didDetermineState:ForRegion delegate methods. Within those methods I am turning ranging on/off.

This all seems to work great except when the CLLocationManager is initialized when the user is already present within the region. In that case neither locationManager:didEnterRegion nor locationManager:DidDetermineState:ForRegion are called until after I exit and then re-enter the region. I was always under the impression that this would at least trigger locationManager:DidDetermineState:ForRegion but that does not appear to be the case.

Is there a way to determine if the user is initially within the region when I first fire off startMonitoringForRegion ?

Upvotes: 5

Views: 1049

Answers (1)

Verticon
Verticon

Reputation: 2513

You can invoke the manager's requestStateForRegion method. This will cause your delegate's didDetermineState method to be called asynchronously.

Upvotes: 7

Related Questions