Installation
Adding Geofence Plugin
Add cordova-moengage-geofence plugin to Cordova project as shown below :
$ cordova plugin add cordova-moengage-geofence
Android Installation
Once you install the Flutter Plugin add MoEngage's native Android SDK dependency to the Android project of your application.
Navigate to android/app/build.gradle. Add the MoEngage Android SDK's dependency in the dependencies block.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation("com.moengage:geofence:$sdkVersion")
}
where $sdkVersion should be replaced by the latest version of the MoEngage Geofence SDK
iOS
In the case of iOS, the native dependency is part of the Geofence Cordova 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 and Android doc 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.
MoEGeofence.startGeofenceMonitoring("YOUR_Workspace_ID");
Stop Geofence Monitoring
If you want to stop the geofence monitoring or feature use the stopGeofenceMonitoring() API. This API will remove the existing geofences.