Smart Geofences
To learn about the Smart Geofences feature, check out this page. Smart Geofences can be configured for an entire population, but not at the individual user level. At the moment, creating geofences directly through the SDK is not supported. Instead, you can provide Sentiance with the list of geofences to configure.
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.
Android
Open your app build.gradle file and add the smart geofences dependency.
dependencies {
implementation(platform("com.sentiance:sdk-bom:<sentiance-version>"))
implementation("com.sentiance:sdk-smart-geofences")
}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
Checkout Real-time Listeners to read more about implementing the SDK's Listeners
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:
If you're calling other Smart Geofences plugin APIs or other 3rd party plugin APIs inside your registerSmartGeofenceEventListener Dart function, then you need to register these plugins with the Sentiance SDK. See this for more details.
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