-
public class AegisGeofenceManagerAegisGeofenceManager — geofence monitoring layer for the Android SDK.
Parity port of the iOS
AegisLocation(Sources/AegisLocation/AegisLocation.swift). Mirrors that module's public shape exactly:Geofence data class (id / label / latitude / longitude / radiusMeters=100 / metadata) — same field set as the iOS
AegisLocation.Geofencestruct and the Flutter / RNGeofence.startMonitoring / stopMonitoring entry points.
onGeofenceEvent closure emitter — the Android analogue of iOS'
setEmitter(_:). Wired by the RN bridge (AegisLocationModule) or directly by a host app to routegeofence.entered/geofence.exitedinto the SDK's track() path.
Platform note — NO per-app cap. Unlike iOS (20 simultaneously-monitored regions per app, which forces the nearest-N-by-SLC strategy in the iOS module), the Android Geofencing API supports up to 100 geofences per
PendingIntent. We therefore register the full configured set directly; there is no nearest-N resort and no significant-location-change machinery.Authorization — the SDK does NOT request location permission. The host app must already hold
ACCESS_FINE_LOCATION(+ACCESS_BACKGROUND_LOCATIONon API 29+ for background fires) before calling startMonitoring. IfaddGeofencesthrowsSecurityExceptionbecause the permission is missing, we log + swallow — geofencing must never crash the host app.objectsingleton (matching ai.aegis.sdk.push.AegisPushTracker) because the GeofenceBroadcastReceiver runs in a separate component and needs to resolve a triggering request-id back to its full Geofence (label / lat / lng / radius / metadata) to build the event envelope — so the configured set is held in process memory here, keyed by id.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classAegisGeofenceManager.GeofenceOne configured geofence — typically derived from an operator's outlet table at SDK init time. Field set mirrors the iOS
AegisLocation.Geofencestruct (radiusMeters defaults to 100m).
-
Field Summary
Fields Modifier and Type Field Description private final IntegerMAX_GEOFENCESprivate Function2<String, Map<String, Object>, Unit>onGeofenceEventpublic final static AegisGeofenceManagerINSTANCE
-
Method Summary
Modifier and Type Method Description final UnitstartMonitoring(Context context, List<AegisGeofenceManager.Geofence> geofences)Configure the set of geofences to monitor. final UnitstopMonitoring(Context context)Stop monitoring all geofences. final IntegergetMAX_GEOFENCES()Android Geofencing API per- PendingIntentlimit.final Function2<String, Map<String, Object>, Unit>getOnGeofenceEvent()Closure-based emitter — the Android analogue of iOS' setEmitter(_:).final UnitsetOnGeofenceEvent(Function2<String, Map<String, Object>, Unit> onGeofenceEvent)Closure-based emitter — the Android analogue of iOS' setEmitter(_:).-
-
Method Detail
-
startMonitoring
final Unit startMonitoring(Context context, List<AegisGeofenceManager.Geofence> geofences)
Configure the set of geofences to monitor. Registers the full set with Play Services (no nearest-N — Android supports up to MAX_GEOFENCES).
Host app MUST hold location permission first; the SDK does not request it. A missing permission surfaces as a
SecurityExceptionfromaddGeofences, which we log + swallow.
-
stopMonitoring
final Unit stopMonitoring(Context context)
Stop monitoring all geofences. Removes the registered PendingIntent from Play Services and clears the in-memory set. Call on logout / opt-out.
-
getMAX_GEOFENCES
final Integer getMAX_GEOFENCES()
Android Geofencing API per-
PendingIntentlimit. Documented in Google'sGeofencingClient.addGeofencesdocs. Far higher than iOS' 20-region cap, so no nearest-N strategy is needed — see class KDoc.
-
getOnGeofenceEvent
final Function2<String, Map<String, Object>, Unit> getOnGeofenceEvent()
Closure-based emitter — the Android analogue of iOS'
setEmitter(_:). Invoked with the canonical event name (geofence.entered/geofence.exited) and a property map keyed with the SAME native-style keys the iOS module emits (geofence_id,geofence_label,geofence_latitude,geofence_longitude,geofence_radius_meters, andgeofence_meta_<k>for each metadata entry). The RN bridge translates these native keys into the RN/Flutter contract envelope keys (geofenceId,geofenceLabel, …,metadata).
-
setOnGeofenceEvent
final Unit setOnGeofenceEvent(Function2<String, Map<String, Object>, Unit> onGeofenceEvent)
Closure-based emitter — the Android analogue of iOS'
setEmitter(_:). Invoked with the canonical event name (geofence.entered/geofence.exited) and a property map keyed with the SAME native-style keys the iOS module emits (geofence_id,geofence_label,geofence_latitude,geofence_longitude,geofence_radius_meters, andgeofence_meta_<k>for each metadata entry). The RN bridge translates these native keys into the RN/Flutter contract envelope keys (geofenceId,geofenceLabel, …,metadata).
-
-
-
-