getMonitoredGeofences

Get all IDs of monitored geofences.

Syntax 

1import { getGeofencingService } from 'lightning/mobileCapabilities';
2getMonitoredGeofences: Promise<[string]>;

Parameters 

None.

Returns 

A Promise object that resolves as an array of string values. The values are unique IDs assigned to monitored geofences. If there’s an error, a rejected promise returns the error type of GeofenceServiceFailure.

Usage 

This function calls all the IDs of monitored geofences.

1myGeofenceService
2  .getMonitoredGeofences()
3  .then((results) => {
4    const activeGeofences = JSON.parse(JSON.stringify(results, undefined, 2));
5    const msg = `Number of geofences: ${activeGeofences.length}`;
6    console.log(msg);
7  })
8  .catch((error) => {
9    const msg = `Failed to get current geofences:${JSON.stringify(error)}`;
10    console.log(msg);
11  });