In order to create an application which alerts the user when he moves within or beyond a set distance from a geolocation, we have the following methods.
Set a new Alert
To create a new alert, we need to create it on the device. To do this we must follow two steps:
1) Create an action (user-defined event executed on the client-side) in the Smart Devices Main object.
This event will be triggered when the alert is fired. For example:
// event code
2) Use the SetProximityAlerts Method, setting the following data:
- Expiration Time
- Action Name
The information must be loaded in a GeolocationProximityAlert SDT -&alert- and added into a collection of the same type -&alerts- for the method to can receive it.
&alert.ActionName = 'ProxAlertNotification'
&alert.Name = 'Test'
&alert.ExpirationTime = #2015-12-31#
&alert.GeoLocation = '-35,-56'
&alert.Radius = 1000
&boolean = GeolocationAPI.SetProximityAlerts(&alerts)
This will fire an alert which is going to execute the event 'ProxAlertNotification' when the user moves within or beyond 1000mts from the geolocation '-35,-56'.
Get the information of the current alert
Execute an event when the alert is fired is optional. But if we do it, we may need to know which alert executed the event to do something with that information.
This method must be used in the event executed by the alert to get the information of it.
&alert = &GeolocationAPI.GetCurrentProximityAlert()
Get the list of active alerts in the device
To get the list of active alerts in the device we should use the method GetProximityAlerts.
&alerts = GeolocationAPI.GetProximityAlerts()
Clear the Proximity Alerts set on the device
In order to delete all the alerts set on a device we need to execute the ClearProximityAlerts method as follows:
Geolocation external object
GeolocationProximityAlert Data Type