Explore the iOS sample app to familiarize yourself with our library, tracking methods, and best practice implementation. The main sample app includes the Location module and an example of the geofencing feature.
Install the Location module with Swift Package Manager, CocoaPods or Carthage. The Location module requires a dispatcher (TealiumCollect or TealiumTagManagement) to transmit location events.
Swift Package Manager (Recommended)
Supported in version 1.9.0+, the Swift Package Manager is the recommended and simplest way to install the Tealium Swift library:
In your Xcode project, select File > Swift Packages > Add Package Dependency
Enter the repository URL: https://github.com/tealium/tealium-swift
Configure the version rules. Typically, Up to next major is recommended. If the current Tealium Swift library version does not appears in the list, then reset your Swift package cache.
Select the Location module from the list of modules to install and add it each of your app targets in your Xcode project, under Frameworks > Libraries & Embedded Content
Apple iOS 14+ provides an app setting for sharing your approximate location rather than your precise location. This method is recommended if your app requires precise location, and if the user initially disabled precise location tracking through their device settings.
If you are not already requesting temporary full authorization in your codebase, use the Tealium helper method requestTemporaryFullAccuracyAuthorization shown in the following example which requests temporary full accuracy.
The geofence feature is enabled by default and location updates are more frequent to provide better accuracy. To enable or disable more frequent location updates, set the useHighAccuracy property.
If you would like a more accurate location and distance setting, set the updateDistance property to a value in meters at which to trigger updates.
There is also an extended accuracy setting, desiredAccuracy that specifies the level of accuracy which the app desires to receive. This is the similar to the CLLocationManager desiredAccuracy property. In iOS 14+, the default value is .reduced and in previous versions it is .nearestHundredMeters.
Geofencing is enabled by default, and to configure geofences, use one of the following methods to provide your geofence JSON file:
Use your own hosted geofences file, provided as a URL to the property geofenceUrl.
This option is recommended if you have overridden the publish settings URL or want to use Hosted Data Layer.
Number of Active Geofences
Geofences are added and removed dynamically, using as few resources as possible. There is no limit to the number of geofences defined, but the number of active geofences is limited to 20 per device user across all running applications.
If a user is within a geofence at the time of creation, the enter transition event does not fire. This is because exit and enter transition events are fired when crossing the perimeter and not when materializing inside.
The following variables are populated by the Location module as part of the mobile data layer. These variables are included automatically in each tracking call from the library.
The latitude of the user’s most recently recorded location
The longitude of the user’s most recently recorded location
The frequency for which the location updates are requested, such as high or low
The accuracy setting for the Location module, such as best or reduced
During geofencing, a tracking call containing location data is sent when the transition state of the user changes. Transition state changes include a user entering or exiting a geofence. The following additional variables are sent to the data layer:
The Tealium tracked geofence event
geofence_entered or geofence_exited
The name of the geofence region
The type of geofence transition event
geofence_entered or geofence_exited
The instantaneous speed of the device, measured in meters per second
The recorded date/time (GMT) the user entered/exited the geofence region
2020-01-28 16:29:46 +0000
For the reference of methods used by the Location module, see the TealiumConfig class in the Tealium SDK for iOS API.