Topics

#7: CLVisit 🚘

Topics

Starting in iOS 8 you can retrieve the places users visit.

class Chauffeur : CLLocationManagerDelegate {
  var manager: CLLocationManager

  func start() { manager.startMonitoringVisits() }
  func stop() { manager.stopMonitoringVisits() }

  // MARK: - CLLocationManagerDelegate

  func locationManager(manager: CLLocationManager!, didVisit visit: CLVisit!) {
    if visit.departureDate.isEqualToDate(NSDate.distantFuture() as! NSDate) {
      // A visit has begun, but not yet ended. User must still be at the place.
    } else {
      // The visit is complete, user has left the place.
    }
  }
}

CLVisit can and does deliver interesting results, but it’s not a slam-dunk yet. Best to use it for journaling-style features, or when it’s okay if it’s not always perfectly accurate. That being said, I tried it out, and was surprised how well it did.

Here's an example "day" it tracked:

CLVisit Pros & Cons

  • πŸ‘ Polite to battery life
  • πŸ‘ Couldn't be simpler
  • 😭 Not very accurate
  • 😭 Visit data often arrives late