To use geofencing, your app must request the following:
- ACCESS_BACKGROUND_LOCATION if your app targets Android 10 (API level 29) or higher
For Geofence pushes to work your Application should have location permission and Play Services' Location Library should be included.
Refer to the documentation for more details.
Add the below dependency in the
$sdkVersion with the appropriate SDK version
geofence artifact should be compatible with the
moe-android-sdk artifact you have already added. Make sure you check the version compatibility table below and pick the right version for your application
Add the Geofence configuration to the
MoEngage.Builder while initializing the SDK using the
val moEngage = MoEngage.Builder(this, "XXXXXXXX") .configureGeofence(GeofenceConfig(isGeofenceEnabled, isBackgroundSyncEnabled)) .build() MoEngage.initialise(moEngage)
MoEngage moEngage = new MoEngage.Builder(this, "XXXXXXXXXXX") .configureGeofence(new GeofenceConfig(isGeofenceEnabled, isBackgroundSyncEnabled)) .build(); MoEngage.initialise(moEngage);
MoEngage SDK optionally notifies the application whenever a Geo-Fence is triggered. If required the application can consume the trigger and ask the SDK not to process it, alternatively, the application can just use the callback for logging/analytical purposes and let MoEngage process the trigger.
To get the callback application needs to implement
OnGeofenceHitListener API Reference and register this listener in the
geofence artifact/module is dependent on the Core SDK or
Based on the version of the Core SDK you are using choose the right version of the Geofence module.
Core SDK Version
11.2.00 and above
1.1.00 and above
11.0.02 - 11.1.00
1.0.00 - 1.0.02
Updated 2 months ago