Location Updates & Geofencing
Pulsate can trigger campaigns when users enter, dwell in, or exit geofences defined in the CMS. This requires location permissions (next page) and location updates being enabled.
Opt in / opt out
Section titled “Opt in / opt out”Location updates are enabled by default (they still do nothing until the user grants location permission). To let users opt out of Pulsate location tracking:
val pulsateManager = PulsateFactory.getInstance()
pulsateManager.setLocationUpdatesEnabled(true) // opt in (default)pulsateManager.setLocationUpdatesEnabled(false) // opt out — stops geofencingRead the current state:
pulsateManager.isLocationUpdatesEnabled(object : IPulsateValueListener<Boolean> { override fun onSuccess(value: Boolean) { /* ... */ } override fun onError(e: Throwable) { }})
// or, from a coroutine:val enabled: Boolean? = pulsateManager.isLocationUpdatesEnabled()Reacting to geofence events
Section titled “Reacting to geofence events”Register a listener to receive the raw enter/dwell/exit events Pulsate processes:
pulsateManager.setGeofenceListener(object : IPulsateGeofenceListener { override fun onTrigger(geofencingEvent: GeofencingEvent?) { // inspect transition type, triggering geofences, location... }})Last known location
Section titled “Last known location”pulsateManager.getLastKnownLocation(object : IPulsateValueListener<Location> { override fun onSuccess(value: Location) { /* android.location.Location */ } override fun onError(e: Throwable) { }})
