Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Understanding the Preferred Geofences services

Updated on August 4, 2022

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.

Pega Customer Decision Hub

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 TypeResponse Content Type
HTTPtext/plain (content is still JSON)
RESTapplication/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.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us