Netmera Developer Guide
Ask or search…
⌃K
Comment on page

iOS Geofence & Location

Netmera SDK does not gather any location information from the device:
By default, Netmera SDK does not gather any location information from the device. If you want to use Netmera features requiring location information such as geofence messages and filtering target users by location, you must enable location tracking for your application.
For using location to target your users, you should enable Location History from the web panel. In order to do that, follow these steps:
Developers -> App Info -> App Config -> Location History Enabled

Step 1. Enable Location Tracking for Your Application

Add appropriate authorization strings to your application target's Info.plist file:

  1. 1.
    If your application will use geofence messages and supports iOS 10 and earlier, you must set NSLocationAlwaysUsageDescription key and add a proper description explaining why your app will use region monitoring, for iOS 11 and above you must set NSLocationAlwaysAndWhenInUseUsageDescription and a proper description.
  • In this case, SDK will monitor region enter/exit actions for geofence regions configured inside Netmera Dashboard.
  1. 2.
    If your application only needs occasional location history information, you can set NSLocationWhenInUseUsageDescription key and add a proper description.
  • In this case, SDK will send the most recent location only once per session.

Step 2. Request Location Authorization

Request location authorization from user by calling the following method in an appropriate place:
Swift
Objective-C
// Request location authorization
Netmera.requestLocationAuthorization()
Calling this method will immediately prompt location permission dialog:
Calling this method will immediately prompt location permission dialog to user, therefore it's important for you to call this method after you informed user about how your application will utilize location.
Setting max regions for geofence:
You can set max regions for Geofence with setNetmeraMaxActiveRegions method. If you set max active regions' number greater than 20 or smaller than 0, it will be set as the default which is 20.
// Request location authorization
[Netmera requestLocationAuthorization];
Calling this method will immediately prompt location permission dialog:
Calling this method will immediately prompt location permission dialog to user, therefore it's important for you to call this method after you informed user about how your application will utilize location.
Setting max regions for geofence:
You can set max regions for Geofence with setNetmeraMaxActiveRegions method. If you set max active regions' number greater than 20 or smaller than 0, it will be set as the default which is 20.
​