Understanding the Preferred Geofences services
The Preferred Geofences set of services can be used to determine the most relevant set of Geofences for a particular location. For example, when a customer launches the app on their device, the app can invoke the service to determine the list of nearby Geofences to monitor. The app can then provide this list to the device’s OS to monitor, thereby avoiding having to continually poll whether the current location has tripped a Geofence.
The following two variants of the service exist:
HandleMktPreferredFences HTTP Service
http://<host>:<port>/prweb/PRHTTPService/PegaMKTGeolocation/Services/HandleMktPreferredFences?Key=Closest&BaseLatitude=<DeviceLatitude>&BaseLongitude=<DeviceLongitude>&ClosestCount=<NumberOfGeofences>
HandleMktPreferredFences REST Service
http://<host>:<port>/prweb/PRRestService/PegaMKTGeolocation/Services/HandleMktPreferredFences/Closest?BaseLatitude=<DeviceLatitude>&BaseLongitude=<DeviceLongitude>&ClosestCount=<NumberOfGeofences>
Both variants expect the following inputs:
- BaseLatitude – Latitude of the device
- BaseLongitude – Longitude of the device
- ClosestCount – Number of closest Geofences to return for the specified location. If this value is not provided, the system returns up to ten Geofences.
The content type for the response differs between the variants:
Service Type | Response Content Type |
HTTP | text/plain (content is still JSON) |
REST | application/json |
A sample (formatted) response is shown below:
{ GeolocationArray : [{ "GeofenceName" : "PegaBedford", "RadiusNormalized" : "1000", "Latitude" : "42.928", "Longitude" : "-71.464" }, { "GeofenceName" : "ManchesterBRAirport", "RadiusNormalized" : "3218.688", "Latitude" : "42.928", "Longitude" : "-71.438" }] }
In error scenarios, such as when the location coordinates are not provided, an error response is returned.
{ ErrorsList : [{ "pyMessage" : "Error: One or more input parameters are invalid." }] }
The system provides out-of-the-box support for closest Geofence lookup (“Key” request parameter is set to “Closest” in the example URLs above). Custom implementations may extend this functionality to provide support for other lookup modes.
Previous topic Understanding geofence services Next topic Understanding the Detect/Trigger services