interface SentianceSmartGeofences {
    addSmartGeofenceEventListener(onSmartGeofenceEvent: ((smartGeofenceEvent: SmartGeofenceEvent) => void)): Promise<EmitterSubscription>;
    getDetectionMode(): Promise<DetectionMode>;
    refreshGeofences(): Promise<void>;
}

Methods

  • Registers a listener for smart geofence events.

    This function sets up an event listener that will execute the provided callback function whenever a smart geofence event occurs (could be an entry, or an exit event).

    Parameters

    • onSmartGeofenceEvent: ((smartGeofenceEvent: SmartGeofenceEvent) => void)

      A callback function that is called whenever a smart geofence event is triggered. The function receives a single argument: a SmartGeofenceEvent object containing details about the event.

    Returns Promise<EmitterSubscription>

    A Promise that resolves to an EmitterSubscription. This subscription object can be used to unsubscribe from the event notifications in the future, by calling remove() on the returned subscription object.

    const subscription = await addSmartGeofenceEventListener(event => {
    console.log('Geofence event received:', event);
    });
    console.log('Listener registered, subscription:', subscription);
  • Retrieves the geofence entry/exit detection mode.

    Returns Promise<DetectionMode>

    const detectionMode = await getDetectionMode();
    console.log('Detection mode is currently:', detectionMode);
  • Refreshes the list of geofences.

    Returns Promise<void>

    A Promise that resolves if the refresh was successful. The Promise does not return any value upon resolution.

    If the refresh fails, the Promise is rejected with an object of type SmartGeofencesRefreshError. This object contains a reason property detailing the nature of the error.

    try {
    await refreshGeofences();
    console.log("Geofences refreshed successfully.");
    } catch (error) {
    const refreshError = error.userInfo as SmartGeofencesRefreshError;
    console.error("Error refreshing geofences:", refreshError.reason);
    }