Location Tracking
The Salesforce CDP Module for the Engagement Mobile SDK supports location tracking for
all events. Enable this functionality using the setLocation method on
the Salesforce CDP Module to set coordinates and
expiresIn.
iOS
Android
1// prepare the coordinates, use the CdpCoordinates wrapper
2let coordinates = CdpCoordinates(latitude: 54.187738, longitude: 15.554440)
3
4// set the location coordinates and expiration time in seconds
5CdpModule.shared.setLocation(coordinates: coordinates, expiresIn: 60)1CdpSdk.requestSdk { sdk >
2 // prepare the coordinates, use the Coordinates wrapper
3 val coordinates = Coordinates(latitude = 54.187738, longitude = 15.554440)
4
5 // set the location coordinates and expiration time in seconds
6 sdk.setLocation(coordinates = coordinates, expiresIn = 60)
7}Given that the SDK has non-expired location coordinates, the location attributes are automatically appended to the event attributes key value pairs with key names latitude and longitude.
When the expiration interval has been exceeded, the SDK location coordinates are cleared and longer attached to events. To prevent location from being attached to events before the coordinates expire, call setLocation and pass nil values as the coordinates.