Source: https://developers.woosmap.com/products/geofencing-sdk/android-sdk/guides/monitor-woosmap-assets/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Monitor Woosmap assets



## Monitor Woosmap Search API assets by automatically generate geofence around its

You need a [Private API key](/api-reference/authentication/#registering-a-woosmap-private-api-key) to request the Woosmap Search API.

To monitor more than 10 points of interest, it is recommended to use Woosmap Search API and load these POIs as Woosmap assets.

Indeed, Search requests help monitoring the approach to some assets you want to monitor. Assets monitoring starts by monitoring the 20 nearest assets and the SDK regularly refresh this list of 20 assets by requesting the Woosmap Search API

To create a circular region around the nearest result of the Search API request, use the passive tracking profile or enable the tracking properties `searchAPICreationRegionEnable`:

```java
WoosmapSettings.searchAPICreationRegionEnable = true
```

But first you have to set keys and set a listener to monitor result of the SearchAPI request :

```java
@Override
protected void onCreate(Bundle savedInstanceState) {
    // Instanciate woosmap object
    this.woosmap = Woosmap.getInstance().initializeWoosmap(this);
​
    // Set private Woosmap key API - It is mandatory for requesting Woosmap Search API and monitor Woosmap Asset
    WoosmapSettings.privateKeyWoosmapAPI = woosmapKey;

    // Instanciate the WoosRegionLogReadyListener to monitor geofence events
    this.woosmap.setRegionLogReadyListener( new WoosRegionLogReadyListener() );
​
    // Passive tracking - Medium accuracy - low power battery usage - no permanent notification in background
    this.woosmap.startTracking( Woosmap.ConfigurationProfile.passiveTracking );
}
```

RegionLog callbacks are triggered each time a user enters or exits a geofence:

```java
public class WoosRegionLogReadyListener implements Woosmap.RegionLogReadyListener {
    public void RegionLogReadyCallback(RegionLog regionLog) {

        // retrieve POI data from the device database
        POI poi = WoosmapDb.getInstance(getApplicationContext()).getPOIsDAO().getPOIbyStoreId(regionLog.idStore);
        Log.d("WoosmapSDKEvents", "Woosmap Geofencing Events:" + regionLog.eventName + " - POI name:" + poi.name);

        // retrieve POI user_properties
        Log.d("WoosmapPOIData", "My property: " + poi.getUserPropertyMap().get("myProperty"));
}
```

You can use `eventName` data to distinguish between enter event (`eventName = "woos_geofence_entered_event"`) and exit event (`eventName = "woos_geofence_exited_event"`).

In the `woos_geofence_exited_event`, an additional data is provided by the regionLog object: `spentTime`
It represents the time spent in the geofence between the entry event and the exit event.

### Radius of assets

To define a custom radius for each asset, create a user property with the key "radius". The expected type for this key is an integer.

It is possible to use the same radius value for all assets, use the `poiRadius` parameter:

```java
WoosmapSettings.poiRadius = 500;
```

## Forcing the refresh of monitored assets

To refresh all POIs immediately without waiting for the automated update, you can use the following method:

```swift
woosmap.refreshPOIs();
```
