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

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 geofencing

Read 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

Register a listener to receive the raw enter/dwell/exit events Pulsate processes:

pulsateManager.setGeofenceListener(object : IPulsateGeofenceListener {
    override fun onTrigger(geofencingEvent: GeofencingEvent?) {
        // com.google.android.gms.location.GeofencingEvent
        // inspect transition type, triggering geofences, location...
    }
})

⚠️

onTrigger is not guaranteed to run on the main thread — dispatch to the main thread before touching UI.

Last known location

pulsateManager.getLastKnownLocation(object : IPulsateValueListener<Location> {
    override fun onSuccess(value: Location) { /* android.location.Location */ }
    override fun onError(e: Throwable) { }
})

ℹ️

Beacons were removed in SDK 4.8.2. The current SDK does geofencing only.