To integrate Geofence, Go to Unity Editor, navigating to Assets > Import Package > Custom Package
and import the Geofence.unitypackage
. The package is part of the .zip
file you downloaded during installation.
Initialization
Add MoEGeofenceGameObject.cs to the same object created in the Unity Initialization step and set the App Id
Android Configuration
Prerequisites for Geofence
To use geofencing, your app must request the following:
- ACCESS_FINE_LOCATION
- ACCESS_BACKGROUND_LOCATION if your app targets Android 10 (API level 29) or higher
warning |
Warning 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 on Geofence.
iOS Configuration
Post integration with the geofence package make sure to Build and Replace for iOS.
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
using MoEngage;
MoEngageGeofenceClient.StartGeofenceMonitoring();
Stop Geofence Monitoring
If you want to stop the geofence monitoring or feature use the StopGeofenceMonitoring() API. This API will remove the existing geofences.
using MoEngage;
MoEngageGeofenceClient.StopGeofenceMonitoring();