Monitoring Geofences - iOS
This document explains how to set up your app to receive Push notifications via Mapp Cloud when a user is in a location of interest.
Add capability for location update in background mode:
Start monitoring geo-locations, and appropriate methods for that.Â
1 | //this part needs to be added at didFinishLaunchingWithOptions method at AppDelegate class Appoxee.shared()?.addObserver(self, forKeyPath: "isReady", options: ( NSKeyValueObservingOptions(rawValue: NSKeyValueObservingOptions.new.rawValue | NSKeyValueObservingOptions.old.rawValue)), context: nil) override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {      if (keyPath == "isReady") {        Appoxee.shared()?.removeObserver(self, forKeyPath: "isReady")               AppoxeeLocationManager.shared()?.delegate = self        AppoxeeLocationManager.shared()?.logLevel = 1        AppoxeeLocationManager.shared()?.enableLocationMonitoring()     }   } //this methods will be triggered if the app is opened while user enter or exit from location func locationManager(_ manager: AppoxeeLocationManager, didFailWithError error: Error?) {      NSLog("Location Error:", error.debugDescription)   }    func locationManager(_ manager: AppoxeeLocationManager, didExitGeoRegion geoRegion: CLCircularRegion) {         //perform something on exit event   }    func locationManager(_ manager: AppoxeeLocationManager, didEnterGeoRegion geoRegion: CLCircularRegion) {       //perform something on enter event   } |
To stop geofence call
AppoxeeLocationManager.shared()?.disableLocationMonitoring() |
On this page user should enable:
Wi-Fi (user must be connected on Wi-Fi network)Â
Location set Always (for specific app user must allows location access always)Â Â Â Â Â Â Â Â Â Â Â
 Â
In the screenshots above you can see which options should be enabled when the user is redirected to Location Service in Settings.Â
Â