Package 

Object AegisGeofenceManager


  • 
    public class AegisGeofenceManager
    
                        

    AegisGeofenceManager — 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.Geofence struct and the Flutter / RN Geofence.

    • 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 route geofence.entered / geofence.exited into 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_LOCATION on API 29+ for background fires) before calling startMonitoring. If addGeofences throws SecurityException because the permission is missing, we log + swallow — geofencing must never crash the host app.

    object singleton (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.

    • 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 SecurityException from addGeofences, 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-PendingIntent limit. Documented in Google's GeofencingClient.addGeofences docs. 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, and geofence_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, and geofence_meta_<k> for each metadata entry). The RN bridge translates these native keys into the RN/Flutter contract envelope keys (geofenceId, geofenceLabel, …, metadata).