To use Geofences to launch campaigns, it is a requirement to have access to the Interactions feature.
This article provides developers information for setting up geo location tracking to allow marketers to configure geo fences.
- Location Permissions
- Enable the geo location feature
- Disable the geo location feature
- Verify/check if the geo location feature is enabled
- Using the setEventHandler
Android SDK Configuration
It is strongly advised that only the Emarsys SDK should be used for geofence management within the app. Using 2 or more geo fencing services within an app may lead to the operating system conflicting between the different sets of geo fences resulting in inconsistent behaviour.
The minimum SDK version should be at least 2.5.0 to support Geofencing,
2. Location Permissions
To request the app has access to the location services of the device, the AndroidManifest.xml must be extended with the following:
... <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> ...
When testing the app, please ensure that the contact is being asked to allow the app access to the geo location.
3. Enable the geo location feature
To enable the geo location feature, use the
Emarsys.geofence.enable(completionListener: CompletionListener? = null)
4. Disable the geo location feature
To disable the geo location feature, use the
5. Verify/check if the geo location feature is enabled
To verify/check if the geo location feature is enabled, use the
6. Using the setEventHandler
In order to react to an event triggered by a geofence, it is possible to register for it using the
setEventHandler method. The eventHandler is a callback for a Geofence event.