How to enable Location Triggered?
Required Permissions:
Region Monitoring(Geofences) requires Always Authorization and Precise location accuracy to be enabled to work. Therefore make sure that the app is configured to get these permissions and also it’s a good practice to let the user know the context in which these permissions are needed, this will also encourage the user to provide these permissions.SDK Installation
Install using Swift Package Manager
MoEngageGeofence is supported through SPM from SDK version 4.2.0. To integrate, use the GitHub url https://github.com/moengage/apple-sdk.git for SDK versions equal and above 9.23.0, or https://github.com/moengage/MoEngage-iOS-SDK.git for other SDK versions link and set the branch as master or required version.Install using CocoaPod
InformationCocoaPods is being deprecated. MoEngage recommends using Swift Package Manager for all new integrations. For more info on CocoaPods, refer to CocoaPods Integration Guide.
pod install to install the framework
Manual Integration
To integrate theMoEngageGeofence SDK manually to your project follow this doc.
Start Geofence Monitoring:
After integrating the MoEngageGeofence module call startGeofenceMonitoring() method to initiate the geofence module. This will fetch the geofences around the current location of the user.didEnterRegion and didExitRegion. You can get these by confirming to the as MoEngageSDKGeofence.sharedInstance.setGeofenceDelegate(self)
Stop Geofence Monitoring:
After version9.3.0 we have provided support to stop the monitoring of geofences. To stop geofence monitoring call stopGeofenceMonitoring() method.
Testing Geofencing
First, create a geofencing campaign on your MoEngage dashboard. You can test geofencing in the following ways:- On the simulator:
-
You can simulate location as shown below.

- Simulate the location for which you have created the campaign on the dashboard. If you get the respective call back (the delegate methods in MoEngageGeofenceHandler), you are good to go. On simulator, you will not receive push notifications.
-
You can simulate location as shown below.
- On the device:
-
You can simulate location for real device from the bar above the console as shown below:

-
You can add a gpx file with the locations configured. A sample gpx file looks like this:
-
You can simulate location for real device from the bar above the console as shown below: