> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-sdk-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Location Triggered

![Download](https://img.shields.io/pub/v/moengage_geofence.svg)

# Installation

To add MoEngage Geofence SDK to your application, edit the application's **pubspec.yaml** file and add the below dependency to it:

<CodeGroup>
  ```pubspec.yaml pubspec.yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
  dependencies:
   moengage_geofence: $latestVersion
  ```
</CodeGroup>

***\$latestVersion*** refers to the latest version of the plugin.

Post including the dependency, run ***flutter pub get*** command in the terminal to install the dependency.

After installing the plugin, use the following platform-specific configuration.

<Info>
  This plugin is dependent on **moengage\_flutter** plugin. Make sure you have installed the **moengage\_flutter** plugin as well. Refer to the [doc](/developer-guide/flutter-sdk/sdk-integration/sdk-installation/framework-dependency) for the same.

  For location-triggered push to work, ensure your Application has:

  * Location permission
  * Play Services Location Library
  * The device's location should be enabled
</Info>

## Android Installation

Starting *****moengage\_geofence5.0.0***** the plugin includes the native dependency, so there is no need to include any additional native dependency.

## iOS Installation

In the case of iOS, the native dependency is part of the Geofence flutter SDK itself, so there is no need to include any additional dependency for supporting Geofence.

## Configuration

### Start Geofence Monitoring

After integrating the geofence package call **startGeofenceMonitoring()** method to initiate the geofence module, this will fetch the geofences around the current location of the user. Please take a look at the [iOS doc](/developer-guide/ios-sdk/push/optional/location-triggered) and [Android doc](/developer-guide/android-sdk/push/optional/location-triggered) for more information on Geofence. By default, the geofence feature is not enabled. You need to call the \*\*startGeofenceMonitoring()\*\*to receive location-triggered push messages. 

<CodeGroup>
  ```Dart Dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import 'package:moengage_geofence/moengage_geofence.dart';
  final MoEngageGeofence _moEngageGeofence = MoEngageGeofence(YOUR_Workspace_ID);
  @override
  void initState() {
    super.initState();
    initPlatformState(); ///Starts Geofence Monitoring
    _moEngageGeofence.startGeofenceMonitoring(); 
  }
  ```
</CodeGroup>

### Stop Geofence Monitoring

If you want to stop the geofence monitoring or feature use the **stopGeofenceMonitoring()** API. This API will remove the existing geofences.

<CodeGroup>
  ```Dart Dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import 'package:moengage_geofence/moengage_geofence.dart';
  final MoEngageGeofence _moEngageGeofence = MoEngageGeofence(YOUR_Workspace_ID);
  @override
  void initState() {
    super.initState();
    initPlatformState(); ///Stops Geofence Monitoring
    _moEngageGeofence.stopGeofenceMonitoring(); 
  }
  ```
</CodeGroup>
