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.
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 belowNote: 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.Callback
The MoEngage SDK can notify your application whenever a geofence is triggered. If the listener returnstrue, 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().