iosswiftlocationcllocationclregion

Is it possible to monitor heading / course after triggering CLRegion?


I mean i would like this to happen :

1 - monitor exiting a region 2 - when the region triggers , i would like to know ex: if the user exiting this region is going North or South and trigger an specific notification based on that ...


Solution

  • Yes, you can start monitoring for heading updates using CLLocationManager.

     if CLLocationManager.headingAvailable() {
           manager.headingFilter = 5
           manager.startUpdatingHeading()
    }
    

    then the CLLocationManager's delegate will provide heading updates via:

    func locationManager(_ manager: CLLocationManager,
                         didUpdateHeading newHeading: CLHeading)