Bubbl uses your device location to fetch the correct campaigns and geofences.
BubblSdk.startLocationTracking(this)This enables the SDK’s background updates and geofence refresh logic.
LocationServices.getFusedLocationProviderClient(this).lastLocation
.addOnSuccessListener { location: Location? ->
if (location != null) {
BubblSdk.refreshGeofence(location.latitude, location.longitude)
} else {
BubblSdk.forceRefreshCampaigns()
}
}Manual refresh ensures geofences are loaded even before the SDK’s periodic refresh runs.
lifecycleScope.launch {
BubblSdk.geofenceFlow.collectLatest { snap ->
snap ?: return@collectLatest
googleMap.clear()
snap.polygons.forEach { poly ->
googleMap.addPolygon(
PolygonOptions()
.addAll(poly.vertices)
.strokeColor(0xFF1976D2.toInt())
.fillColor(0x331976D2)
)
}
}
}Tooltip
This is a debug visualization. You can omit map dependencies in production apps.