Monitor user's Visits

How to track user’s Visits and identify his Zone of interest on iOS.

  1. Collect user’s Visits
  2. Zone of Interest (ZOI)

Get the location and the time spent when a user is visiting places. These use cases are explained in the Visit and ZOI documentation.

Collect user’s Visits

Set up for Visits monitoring

The first step in collecting Visits is to set visitDelegate, this should be done as early as possible in your didFinishLaunchingWithOptions App Delegate. It is recommended to use the visitsTracking profile to monitor visits and identify ZOI. You can also enable the visitEnable setting if you don’t want to use a preset tracking profile.

swift
        let dataVisit = DataVisit()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // Set delegate of protocol Visit
        WoosmapGeofenceManager.shared.getLocationService().visitDelegate = dataVisit
        
        WoosmapGeofenceManager.shared.startTracking(configurationProfile: ConfigurationProfile.visitsTracking)
}

    

Visit Service Delegate

In your class delegate, retrieve and delete Visit data:

swift
        public class DataVisit:VisitServiceDelegate  {
    
    public init() {}

    public func processVisit(visit: Visit) {
        // this method is called when a visit is collected
    }
    
    public func readVisits()-> Array<Visit> {
        return Visits.getAll()
    }
    
    public func eraseVisits() {
        Visits.deleteAll()
    }
}

    

Zone of Interest (ZOI)

Set up for ZOI monitoring

ZOIs are built from visits, grouped by proximity. The Geofencing SDK implements the Fast Incremental Gaussian Mixture Model of classification Algorithm FIGMM to build and update the ZOI according to visits recurrence over time.

For the ZOIs, in the app delegate, you can retrieve zoi data like this:

swift
        public class DataZOI {
    public init() {}
    
    public func readZOIs()-> [ZOI] {
        return ZOIs.getAll()
    }
    
    
    public func eraseZOIs() {
        ZOIs.deleteAll()
    }
}

    

Each ZOI includes the following information:

Field name Type Description
zoiId UUID The unique identifier of the ZOI.
idVisits [UUID] The list of id visits included in this ZOI.
latMean Double The latitude of the center of the ZOI (useful if you need to qualify the place of the visit with a search request over POIs or assets)
lngMean Double The longitude of the center of the ZOI (useful if you need to qualify the place of the visit with a search request over POIs or assets)
startTime DateTime The entry date for the first ZOI visit.
endTime DateTime The exit date of the last ZOI visit
duration Int64 The duration of all the accumulated visits of the ZOI
wktPolygon String This is the Well-known text representation of geometry of the ZOI polygon.
Was this article helpful?
Have more questions? Submit a request