Start tracking geofence

Prev Next

To effectively use Insider Geofence in your Android application, follow the steps below.

1. Ensure the required dependencies are added

Before proceeding, ensure that all necessary dependencies have been added to your project.

2. Configure location permissions

Add the following permissions to AndroidManifest.xml to allow location access.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Your title goes here
According to Google Play Policy, app owners must obtain explicit user consent before collecting the location data. Users must allow "Always" and "Fine Location" permissions for geofencing to work correctly. If the location opt-in is set to false, geofencing will not function. To understand how to collect user consent, refer to Google Play Console - User Data.

3. Set location opt-in to true

Once the user grants location permissions, update the location opt-in status for Insider.

Your title goes here
Before setting the location opt-in, ensure Android's location permissions are enabled. The location opt-in must be set to true for geofencing to work.

4. Start tracking geofences

Once location permissions are granted and opt-in is enabled, call the following method to start tracking geofences.

Method Signature

public void startTrackingGeofence()
fun startTrackingGeofence()

Method Example

Insider.Instance.startTrackingGeofence();

Your title goes here
  • You can track up to 20 geofences per user. 
  • If geofencing does not work, check if:
    • The location permissions are granted.
    • The location opt-in is set to true.
    • SDK is initialized correctly.

5. Debugging and verification

After completing all steps, enable the SDK Debug Mode to verify that geofencing is working correctly. The tracked geofences will be visible in the SDK logs.