Packages dependencies If you intend to use the this service you have to make sure that the
geofencing
package have been properly downloaded. You can easily check if the package is available on the device with the following method:ISSite#hasPackage(EPackageType.GEOFENCING);
.
To start the Geofencing
module, simply do like so:
// Retrieve the geofencing module
geofenceProvider = (ISGeofenceProvider) ISLocationProvider.getInstance().getModule(ISELocationModule.GEOFENCING);
// Register as a IGeofenceListener
geofenceProvider.setListener(listener);
After starting the module, your delegate will be notified with 3 arrays of ISGeoFenceArea
.
- The first one contains all zones the user just entered.
- The second one contains all zones where the user still is and has spent a certain time.
- The third one contains all zones the user just left.
/**
* Called when geofencing module has new data available.
* @param enteredAreas list of areas that location has just entered
* @param stayedAreas list of areas where location has stayed for a certain amount of time
* @param leftAreas list of areas that location has just left
*/
@Override
public void onGeofenceUpdate(List enteredAreas, List stayedAreas, List leftAreas) {
Log.d("Geofencing", " onGeofenceUpdate: " + enteredAreas.size() + ", "
+ stayedAreas.size() + ", " + leftAreas.size());
}
In the last version of our API, geopush content can be added to the ISGeofenceProvider
directly from your application in addition to the one fetched from the server. This enables, for example, your content to be more accurate to a specific user's behaviour or using context.
- The created
ISGeofenceArea
's polygon will be based on the specificISZone
parameters that have to be provided in the back office. - If the
ISGeofenceArea
parameters (ie width, enteredTime, enteredEnabled ... ) are not set they will be fetched from the configuration file. This configuration file defines those parameters byISMap
and not byISZone
. - If the creation succeeded the
ISGeofenceArea
will be automatically added to theISGeofenceProvider
.
To add a geopush content to a specific ISZone
or ISZonePoi
, you can use the methods shown below.
A polygon based on the ISZone parameters and the provided ISGeofenceArea
width will be created and this ISGeofenceArea
will be automatically added to the ISGeofenceProvider
.
// For a Zone
public ISGeofenceArea addGeofenceArea(int zoneId, String content);
public ISGeofenceArea addGeofenceArea(int zoneId, String content, long eventTime);
public ISGeofenceArea addGeofenceArea(int zoneId, String content, boolean enteredEnabled, long enteredTime, boolean stayedEnabled, long stayedTime, boolean leaveEnabled, long leaveTime, float width);
// For a ZonePoi association
public ISGeofenceArea addGeofenceArea(ISZonePoi zonePoi, String content);
public ISGeofenceArea addGeofenceArea(ISZonePoi zonePoi, String content, long eventTime);
public ISGeofenceArea addGeofenceArea(ISZonePoi zonePoi, String content, boolean enteredEnabled, long enteredTime, boolean stayedEnabled, long stayedTime, boolean leaveEnabled, long leaveTime, float width);
To add a geopush content at a specific ISPosition
, you can use the methods shown below.
A square of size on the given parameter (or by default 4 time the size defined in the configuration file) and center on the given position will be created.
public ISGeofenceArea addGeofenceArea(String guid, ISPosition center, String content);
public ISGeofenceArea addGeofenceArea(String guid, ISPosition center, String content, long eventTime);
public ISGeofenceArea addGeofenceArea(String guid, ISPosition center, String content, boolean enteredEnabled, long enteredTime, boolean stayedEnabled, long stayedTime, boolean leaveEnabled, long leaveTime);
public ISGeofenceArea addGeofenceArea(String guid, ISPosition center, float size, String content);
public ISGeofenceArea addGeofenceArea(String guid, ISPosition center, float size, String content, long eventTime);
public ISGeofenceArea addGeofenceArea(String guid, ISPosition center, float size, String content, boolean enteredEnabled, long enteredTime, boolean stayedEnabled, long stayedTime, boolean leaveEnabled, long leaveTime);
To remove a ISGeofenceArea
from the ISGeofenceProvider
call the appropriate remove method based on how it was added.
public void removeGeofenceArea(String guid);
public void removeGeofenceArea(int zoneId);
public void removeGeofenceArea(ISZonePoi zonePoi);
public void removeGeofenceArea(ISGeofenceArea area);
You can now view your ISGeofenceArea
on your ISMapView
. Like all other LBS services, you will have to retrieve its ISRenderer
and pass it to the ISMapView
. All the geofencing zone will be displayed ie the one define on the back office that one created dynamically.
Note: 3D rendering is not available for this module.