Smart Geofences
Prerequisites
The Smart Geofences feature relies on additional library dependencies alongside the core SDK dependency. To start using this feature, you must first add these dependencies to you project.
Utilize the Smart Geofences APIs
In this section, you’ll find examples showing how to subscribe for geofence entry and exit events, how to force-update the geofence list, and how to check the geofence monitoring status.
Listen to Smart Geofence Entry and Exit Events
You can subscribe to receive geofence entry and exit event notification as they are detected.
To get smart geofence entry/exit event updates even when your app is in the background, place the following code inside your app's entrypoint index.js file. If you're only interested in these updates when your app is foregrounded, place this code inside the appropriate UI code instead.
Create a background.dart file under your project's lib folder with the following code:
Add the following code, depending on your target platform.
For iOS, add the following to your app delegate class:
For Android, add this code to your custom application class:
Refresh the List of Monitored Geofences
The SDK regularly refreshes the list of monitored geofences. You can request an immediate refresh as follows:
Get the Current Smart Geofences Detection Mode
You can check the smart geofences detection mode as follows:
When enabled, the detection mode can either be in the foreground (i.e when the app is visible), or both foreground and background, depending on the type of location permission that has been granted (i.e. "always" or "while-in-use").
When detection mode is disabled, it indicates a general issue with the SDK’s detection. You can check the SDK status to identify the cause.
Last updated