Develop Secure Code
GeofencingService Data Types
getGeofencingService()
isAvailable()
startMonitoringGeofence()
stopMonitoringGeofence()
stopMonitoringAllGeofences()
getMonitoredGeofences
Get all IDs of monitored geofences.
1import { getGeofencingService } from 'lightning/mobileCapabilities';
2getMonitoredGeofences: Promise<[string]>;None.
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.
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 });