The purpose of this article is to explain the necessary steps to use Location Proximity Alerts to solve Geofencing with GeneXus.
The following methods are used to create an application to alert the user when moving within or beyond a defined distance from a geolocation.
New alerts are created on the device. To do this, follow two steps:
1. Create an action (user-defined event executed on the client-side) in the Main object.
This event will be executed when the alert is triggered. For example:
// event code
2. Use the SetProximityAlerts method, and set up the following data:
- Expiration Time
- Action Name
The information must be loaded in a GeolocationProximityAlert SDT -&alert-, and added to a collection of the same type -&alerts- so that the method can receive it.
&alert.ActionName = 'ProxAlertNotification'
&alert.Name = 'Test'
&alert.ExpirationTime = #2015-12-31#
&alert.GeoLocation = '-35,-56'
&alert.Radius = 1000
&boolean = Maps.SetProximityAlerts(&alerts)
This will trigger an alert that will execute the event 'ProxAlertNotification' when the user moves within or beyond 1000mts from the geolocation '-35,-56'.
Executing an event when the alert is triggered is optional. But if you do it, you must know which alert executed the event, in order to do something with that information.
This method must be used in the event executed by the alert to get the information on it.
&alert = Maps.GetCurrentProximityAlert()
To get the list of active alerts on the device, you should use the GetProximityAlerts method.
&alerts = Maps.GetProximityAlerts()
In order to delete all the alerts set on a device, you must execute the ClearProximityAlerts method as follows:
You can download the sample here: Geolocation Proximity Alerts Sample.
Geolocation external object
GeolocationProximityAlert Data Type