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" />3. Set location opt-in to true
Once the user grants location permissions, update the location opt-in status for Insider.
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();- 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.