Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 327
nwales Avatar asked Mar 13 '23 13:03

nwales


1 Answers

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

like image 140
Verticon Avatar answered Apr 09 '23 12:04

Verticon