Geofence & Location
By default, Netmera SDK does not collect location information from the device. To use features like geofence messaging and location-based user targeting, you must enable location tracking.
Step 1: Enable Location History
To use location-based targeting, enable Location History in the Netmera web panel: Developers > App Info > App Config > Location History Enabled
Step 2: iOS Integration
1. Configure Location Permissions
Add the necessary authorization keys to your Info.plist file:
For Geofence Messaging (iOS 10 and earlier)
Set
NSLocationAlwaysUsageDescription
with a description explaining why the app uses region monitoring.This allows the SDK to monitor region entry/exit actions for geofence regions configured in the Netmera Dashboard.
For Geofence Messaging (iOS 11 and later)
Set
NSLocationAlwaysAndWhenInUseUsageDescription
with a description explaining why the app uses region monitoring.This allows the SDK to monitor region entry/exit actions for geofence regions configured in the Netmera Dashboard.
For Occasional Location Updates
Set
NSLocationWhenInUseUsageDescription
with a description.This sends the most recent location once per session.
Step 3: Android Integration
On Android 10 and later, geofence push notifications require background location access. However, Android does not allow apps to request this permission directly in the app. Instead, users must manually enable "Allow all the time" in the system settings.
Best Practice: Before redirecting users to settings, display an explanatory message about why location access is needed. You can use Netmera widgets to communicate this effectively. You may see the next page Background Location Permission on how to create these widgets to ask for location permissions.
1. Add Required Permissions
In your AndroidManifest.xml file, add the following permissions:
2. Configure Location Hardware Requirements (Optional)
If your app requires location-based services but should still be visible on devices without GPS hardware, add the following declarations in AndroidManifest.xml:
Step 4: Location Authorization
For Android 6.0 (API Level 23) and later, location permission must be requested while the app is running. Netmera provides a built-in permission request flow:
Calling these methods immediately prompts the location permission dialog. Make sure to inform users beforehand about how your application will use their location.
Step 5: Geofence Region Limits (Optional)
To set the maximum number of active geofence regions, use:
For iOS: If the value is set greater than 20 or less than 0, it will be automatically reset to 20.
For Android: If you set a value greater than 95 or less than 0, it will be reset to the default (95).
Troubleshooting
Geofence Update Events: Common Causes and Solutions
The Netmera SDK triggers the Geofence Update event when there is a change in the geofence area, prompted by the operating system. However, if the operating system does not trigger this event, you may not see the geofence update events. This can occur due to various reasons such as operating system limitations or device settings.
Last updated
Was this helpful?