The purpose of this article is to explain the necessary steps to use Geolocation Proximity Alerts.
The following methods are used to create an application which alerts the user when moving within or beyond a set distance from a geolocation.
New alerts are created on the device. To do this, follow these two steps:
1. Create an action (user-defined event executed on the client-side) in the Main object.
This event will be excecuted when the alert is triggered. For example:
Event 'ProxAlertNotification'
// event code
EndEvent
2. Use the SetProximityAlerts method, setting the following data:
- Name
- Description
- Geolocation
- Radius
- Expiration Time
- Action Name
The information must be loaded in a GeolocationProximityAlert SDT -&alert- and added into a collection of the same type -&alerts- so 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 = Geolocation.SetProximityAlerts(&alerts)
This will trigger an alert which is going to execute the event 'ProxAlertNotification' when the user moves within or beyond 1000mts from the geolocation '-35,-56'.
Execute an event when the alert is triggered is optional. But if you do it, you 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 = &Geolocation.GetCurrentProximityAlert()
To get the list of active alerts in the device, you should use the GetProximityAlerts method.
&alerts = Geolocation.GetProximityAlerts()
In order to delete all the alerts set on a device, you need to execute the ClearProximityAlerts method as follows:
Geolocation.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