HowTo: Use Geolocation Proximity Alerts

Official Content
This documentation is valid for:

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.

Steps to set a new Alert

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'.

Get the information of the current alert

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()

Get the list of active alerts in the device

To get the list of active alerts in the device, you should use the GetProximityAlerts method.

&alerts = Geolocation.GetProximityAlerts()

Clear the Proximity Alerts set on the device

In order to delete all the alerts set on a device, you need to execute the ClearProximityAlerts method as follows:

Geolocation.ClearProximityAlerts()

Considerations

  • In order to use this feature on Apple devices, set the Location Always usage description.
  • In order to use this feature on Android devices, enable Use Proximity Alert property at Native Mobile Main object properties. The purpose of this property is to indicate that the alerts must be recovered after a device reboot.

Sample

You can download the sample here: Geolocation Proximity Alerts Sample.

See Also

Geolocation external object
SetProximityAlerts method
GetCurrentProximityAlert method
GetProximityAlerts method
ClearProximityAlerts method
GeolocationProximityAlert Data Type