Skip to main content

Prerequisites

To use location triggered (Geofence) push, your app must request the following:
  • ACCESS_FINE_LOCATION
  • ACCESS_BACKGROUND_LOCATION if your app targets Android 10 (API level 29) or later.
For location triggered push to work, ensure your Application has the following enabled: Location permission, Play Services location library, and device’s location.
For more information, refer to Android Request Geofences.

SDK Installation

Installing using BOM

Integration using BOM  is the recommended way of integration; refer to the Install Using BOM document. Once you have configured the BOM add the dependency in the app/build.gradle file as shown below
Once the BOM is configured, include the specific MoEngage modules required for the application. 
Note: Version numbers are not required for these dependencies; the BOM automatically manages them.

Configure Geofence

By default, the geofence feature is not enabled. To enable the feature, call the below API.
At any time if you want to stop the geofence monitoring or feature, use the below API. This API will remove the existing geofences.

Callback

The MoEngage SDK can notify your application whenever a geofence is triggered. If the listener returns true, your application consumes the trigger and the SDK doesn’t process it further. Returning false lets the SDK process the trigger as usual, so the listener can be used purely for logging or analytics. Implement OnGeofenceHitListener and register it in your Application class onCreate() using MoEGeofenceHelper.getInstance().addListener().