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 'ProxAlertNotification'
// event code
EndEvent
2. Use the SetProximityAlerts method, and set up the following data:
- Name
- Description
- Geolocation
- Radius
- 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
&alerts.Add(&alert)
&boolean = Maps.SetProximityAlerts(&alerts)
This will trigger an alert that will execute the event 'ProxAlertNotification' when the user moves within or beyond 1000m 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:
Maps.ClearProximityAlerts()
You can download the sample here: Geolocation Proximity Alerts Sample.
Geolocation external object
SetProximityAlerts method
GetCurrentProximityAlert method
GetProximityAlerts method
ClearProximityAlerts method
GeolocationProximityAlert Data Type