startMonitoringGeofence()

Start monitoring a geofence region.

Syntax 

1import { getGeofencingService } from 'lightning/mobileCapabilities';
2startMonitoringGeofence(
3    geofence: Geofence
4): Promise<string>;

Parameters 

  • geofence—(Required) A Geofence object to monitor.

Returns 

A Promise object that resolves as a string value. The value is a unique ID that’s assigned to the monitored geofence. If there’s an error, a rejected promise returns the error type of GeofenceServiceFailure.

Usage 

Use this function to start monitoring of a geofence. 

1myGeofenceService.startMonitoringGeofence(geofence)
2   .then((id) => {
3       const msg = `ID for geofence created: ${id}`;
4       console.log(msg);
5   })
6   .catch((error) => {
7       const msg = `Failed to start monitoring:${JSON.stringify(error)}`; 
8       console.log(msg);
9   });

Your callback function is called to return the ID of the geofence that’s been created. To stop monitoring the geofence in the future, retain the geofence ID.

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.