Android 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.
Geofence Push Notifications on Android 10 and Above
In order to send geofence push notifications on Android 10 and above, it's necessary to request background location permission from users. Ensure that you have added the required permission to your AndroidManifest.xml
file. However, please note that Android does not allow apps to collect this permission directly within the app. Instead, you need to direct users to the settings screen, where they must manually select "Allow all the time" for the app to track geofences properly.
Before redirecting users to the settings, we recommend displaying a message to inform them why the permission is needed. Android guidelines encourage providing context before sending users to settings, ensuring transparency. You can use our widgets, as outlined in the user documentation here to present this communication message to your users effectively.
Step 1. Add Permissions
Add following two location permissions to your AndroidManifest file.
Step 2. Request Permissions
Only for Android 6.0 (API Level 23) and later, location permission must be requested while app is running depending to your app's targetSdkVersion. For more info please refer to this link. The implementation of runtime permission request is complicated but Netmera has already have permission request flow for location permissions. All you have to do is calling following method in some appropriate place of your app's flow.
After you call that method, default permission dialog will be shown to the user if app has not already been granted the location permission. After the user allows, Netmera will perform location operations according to your settings on Netmera Dashboard.
Setting max regions for geofence:
You can set max regions for Geofence with setNetmeraMaxActiveRegions method. If you set max active regions' number greater than 95 or smaller than 0, it will be set as the default which is 95.
Step 3. Location History Enabled
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
Done Now, your app can use location features of Netmera SDK.
Go to your app on Netmera Dashboard make following configurations according your needs:
Enable location history for location tracking
Add some Geofence places for region tracking
Optional: Android Manifest
For applications that require hardware, you must use the ** ** declaration to view the app in the store on devices that do not have this feature.
To use geofence or location-based push services via Netmera, location hardware is required in the devices. You need to add the following GPS declaration into your manifest file.
Troubleshooting
If you encounter the following crash and are using gms:play-services-location
, it is advisable to upgrade to version 21.0.1.
Last updated