To integrate Geofence, Go to Unity Editor, navigating to Assets > Import Package > Custom Package
and import the Geofence.unitypackage
The above package is part of the .zip
file you downloaded during installation.
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.
Configure Geofence
Add the Geofence configuration to MoEngage.Builder
while initializing the SDK using the configureGeofence()
MoEngage moEngage = new MoEngage.Builder(this, "XXXXXXXXXXX")
.configureGeofence(new GeofenceConfig(isGeofenceEnabled, isBackgroundSyncEnabled))
.build();
MoEngage.initialise(moEngage);
iOS Configuration
First, integrate the MoEngageGeofenceiOS
unity package as mentioned in the initialization doc. Post which you will have to Build and Replace for iOS.
Post integrating the Geofence package, call StartGeofenceMonitoring()
method as shown below to support geofence campaigns in your iOS app:
using MoEngage;
// Only for iOS
MoEngageClient.StartGeofenceMonitoring();