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