THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Documentation

IMPORTANT: The TomTom Geofencing API and Geofencing module in the Maps SDK for iOS are currently in Public Preview. To find out what our Public Preview is and to revisit our Terms and Conditions, see this Public Preview Page

Initialization

In order to use Geofencing you will need the appropriate Geofencing API Key. For more information on obtaining and configuring TomTom API Keys and their configuration, go to the "Getting started" page.

Create a Geofencing API object in the following manner:

service = TTGeofencingReportService(key: Key.Geofencing)
_service = [[TTGeofencingReportService alloc] initWithKey:Key.Geofencing]

The Geofencing API provides you with the ability to define virtual barriers on real geographic locations. With geofenced object location you can determine if that object is located within or outside of predefined virtual barriers on real geographic locations.

The Geofencing API offers a number of services including the Configuration service, Report service, Projects service, Fences service, Objects service, Transitions service, and Archive service. Details are available in the Geofencing API. Currently, the Maps SDK only offers the Report service.

Report service

The Report service allows you to generate a location report which determines if an object is within fences. The Response of this service contains a summary and:

  • A list of fences that the object/point is inside of.
  • A list of fences within a specified radius that the object is not inside of.

If no fences match the Request parameters, then the list returned in the Response can be empty. The outside fences list can only be empty if there are no more fences left in the project.

To use a Report service you need to have at least one project defined within a configuration.

For your mobile app you can use a standard listener approach or Reactive approach when preparing the Report service Request.

The first approach involves using the reportWithQuery method, taking the TTGeofencingReportQuery as a parameter.

To obtain a report for an object you will need to create a query in the following manner:

1let reportQuery = TTGeofencingReportQueryBuilder(location: TTLocation(coordinate: coordinate))
2 .withProject(projectId)
3 .withRange(range).build()
TTGeofencingReportQuery *reportQuery = [[[[[TTGeofencingReportQueryBuilder alloc] initWithLocation:[[TTLocation alloc] initWithCoordinate:coorinate]] withProject:projectId] withRange:_range] build];

Now you can perform a Report service Request by calling:

1service?.report(with: reportQuery) { report, _ in
2 self.responseGeofencing(report: report)
3}
1[_service reportWithQuery:reportQuery
2 completionHandle:^(TTGeofencingReport *_Nullable report, TTResponseError *_Nullable error) {
3 [weakSelf responseGeofencing:report];
4 }];