LocationModule

Reference guide for LocationModule class and methods provided by Tealium for iOS (Swift).

Class: LocationModule

The LocationModule class provides methods for gathering location data, creating and monitoring geofences. The following summarizes methods of the LocationModule class for Tealium iOS (Swift) which can be used to make custom changes to the default behavior of the Location Module. For additional details, explore Location.

Method Description
clearMonitoredGeofences() Removes all currently monitored geofences from the location client
getCreatedGeofences() Returns the names of all the created geofences (those currently being monitored and those that are not)
getLastLocation() Gets the last known location for a user’s device
getMonitoredGeofences() Returns the names of all currently monitored geofences
requestAuthorization() Prompts the user to enable permission for location servies
requestTemporaryFullAccuracyAuthorization() Automatically requests temporary full accuracy if precise accuracy is disabled
startLocationUpdates() Enables regular updates of location data through the location client
stopLocationUpdates() Stops the updating of location data through the location client
startMonitoring() Adds geofences to the location client to be monitored
stopMonitoring() Removes geofences from being monitored by the location client

clearMonitoredGeofences()

Removes all currently monitored geofences from the location client.

tealium.location?.clearMonitoredGeofences()

getCreatedGeofences()

Returns the names of all the created geofences (those currently being monitored and those that are not).

tealium.location?.getCreatedGeofences(completion: { createdGeofences in
            if let createdGeofences = createdGeofences {
                // use geofences here
            }
        })

getLastLocation()

Gets the last known location for a user’s device.

tealium.location?.getLastLocation(completion: { lastLocation in
            if let lastLocation = lastLocation {
                // use last location here
            }
        })

getMonitoredGeofences()

Returns the names of all currently monitored geofences.

tealium.location?.getMonitoredGeofences(completion: { monitoredGeofences in
            if let monitoredGeofences = monitoredGeofences {
                // use monitored geofences here
            }
        })

requestAuthorization()

Prompts the user to enable permission for location servies.

tealium.location?.requestAuthorization()

requestTemporaryFullAccuracyAuthorization()

Automatically requests temporary full accuracy if precise accuracy is disabled.

let purposeKey = "a key in the NSLocationTemporaryUsageDescriptionDictionary"
tealium.location?.requestTemporaryFullAccuracyAuthorization(purposeKey: purposeKey)
Parameters Type Description
purposeKey String A key in the NSLocationTemporaryUsageDescriptionDictionary dictionary of the app’s Info.plist file

startLocationUpdates()

Enables regular updates of location data through the location client. Update frequency is dependent on config.useHighAccuracy, a parameter passed on initialization of this class.

tealium.location?.startLocationUpdates()

stopLocationUpdates()

Stops the updating of location data through the location client.

tealium.location?.stopLocationUpdates()

startMonitoring()

Adds geofences to the location client to be monitored.

let myGeofences = [CLCircularRegion]() // Store your self-managed geofences somewhere if you want to stop them later
tealium.location?.startMonitoring(geofences: myGeofences)
Parameters Type Description
geofences [CLCircularRegion]() Geofences to be added

stopMonitoring()

Removes geofences from being monitored by the location client.

tealium.location?.stopMonitoring(geofences: myGeofences)
Parameters Type Description
geofences [CLCircularRegion]() Geofences to be removed

Was this page helpful?

This page was last updated: January 7, 2023