Location Triggered 11.x.x

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.
info

Note

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

  •  
    • Location permission
    • Play Services Location Library
    • The device's location should be enabled

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

build.gradle
dependencies {
    ...
    implementation("com.moengage:geofence")
}

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

Add the Geofence configuration to the MoEngage.Builder while initializing the SDK using the configureGeofence().

Kotlin Java
val moEngage = MoEngage.Builder(this, "XXXXXXXX")
        .configureGeofence(GeofenceConfig(isGeofenceEnabled, isBackgroundSyncEnabled))
        .build()
MoEngage.initialise(moEngage)

Geofence Hit Callback

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.

For more information about implementing callback in the application using OnGeofenceHitListener, refer to API Reference.

Register the listener in the Application class 'onCreate ()` using MoEGeofenceHelper.getInstance().addListener().

Version Compatibility

Core SDK Version Geofence
11.4.02 - 11.6.01 1.2.00 - 1.2.2
11.2.00 - 11.3.01 1.1.00
11.0.02 - 11.1.00 1.0.00 - 1.0.02

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?