MoEngage Docs





  • From MoEngage-iOS-SDK version 4.3.0 Geofence module is separated from the SDK to a separate module MOGeofence and hence has to be added separately.

  • Region monitoring (Geofence feature) is only supported with Always authorization. When-in-use authorization doesn't support this feature. Refer link for more info.

  • Dwell trigger is not supported in iOS, hence the SDK supports only Enter and Exit triggers.

How to enable Geofence ?

First, include the MOGeofence in the pod file and run pod install

pod 'MOGeofence','~> 2.0.0'



To integrate the MOGeofence SDK manually to your project follow this doc.

After integrating the MOGeofence module call this method to initiate the geofence module.

[[MOGeofenceHandler sharedInstance] startGeofenceMonitoring];

This will fetch the geofences around the current location of the user.
Geofence Handler also has callbacks for didEnterRegion and didExitRegion. You can get these by confirming to the MOGeoDelegate.

class ViewController: UIViewController, MOGeoDelegate
        func locManager(_ locationManager: CLLocationManager!, didEnter region: CLRegion!) {
            print("GeoFence Entered")
        func locManager(_ locationManager: CLLocationManager!, didExitRegion region: CLRegion!) {
            print("GeoFence Exit")      
@interface MyViewController ()<MOGeoDelegate>
-(void)locManager:(CLLocationManager *)locationManager didEnterRegion:(CLRegion *)region{
    NSLog(@"GeoFence Entered");
-(void)locManager:(CLLocationManager *)locationManager didExitRegion:(CLRegion *)region{
    NSLog(@"GeoFence Exit");

Testing Geofencing

First, create a geofencing campaign on your MoEngage dashboard. You can test geofencing in the following ways:

  1. On the simulator:
    a). You can simulate location as shown below.
b). Simulate the location which for which you have created the campaign on the dashboard.

If you get the respective call back (the delegate methods in MOGeofenceHandler), you are good to go. On simulator you will not receive push notifications.

  1. On the device:
    a) You can simulate location for real device from the bar above the console as shown below:

b) You can add a gpx file with the locations configured. A sample gpx file looks like this:

<?xml version=“1.0”?>
<gpx version=“1.0”>
    <wpt lat=“12.9719” lon=“77.6412”><name>CustomName</name></wpt>
    <wpt lat=“12.9619” lon=“77.6312”></wpt>
    <wpt lat=“12.9519” lon=“77.6112”></wpt>

On the device, once you get the delegate callback for enter or exit in a region, a notification will be sent to the device. This happens instantly, but the notification might take upto 10 minutes.

Geo Notifications

Once you have received the notification, to identify geo notifications, there is a custom param “cType” = “geo” in the param app_extra, as shown below:

    "app_extra" = {
            cType = geo;
            screenData = {
                "" = "";
            screenName = "";
        aps = {
            alert = "exit london- single fence";
            badge = 1;
        moengage = {
            cid = "55a628bcf4c4073bb66a368b_GEO:55a628bcf4c4073bb66a368c_ABab1:2015-07-15_14:11:33.704706";

Updated 3 months ago

What's Next



Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.