Places API reference
This document contains usage information for the public functions, classes, and enums in AEPPlaces.
This page only contains information about the 3.x AEPPlaces
extension.
A full API reference for the 2.x ACPPlaces
extension for iOS can be found here.
clear
Clears out the client-side data for Places in shared state, local storage, and in-memory.
extensionVersion
Returns the running version of the AEPPlaces extension.
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet placesVersion = Places.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *placesVersion = [AEPMobilePlaces extensionVersion];
Java
Example
Copied to your clipboardString placesExtensionVersion = Places.extensionVersion();
Kotlin
Example
Copied to your clipboardval placesExtensionVersion: String = Places.extensionVersion()
Swift
Syntax
Copied to your clipboardstatic var extensionVersion: String
Example
Copied to your clipboardlet placesVersion = Places.extensionVersion
Objective-C
Syntax
Copied to your clipboard+ (nonnull NSString*) extensionVersion;
Example
Copied to your clipboardNSString *placesVersion = [AEPMobilePlaces extensionVersion];
getCurrentPointsOfInterest
Returns all points of interest (POI) of which the device is currently known to be within.
Java
Example
Copied to your clipboardPlaces.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {@Overridepublic void call(List<PlacesPOI> pois) {// use the obtained POIs that the device is withinprocessUserWithinPois(pois);}});
Kotlin
Example
Copied to your clipboardPlaces.getCurrentPointsOfInterest() { pois ->// use the obtained POIs that the device is withinprocessUserWithinPois(pois)}
Swift
Syntax
Copied to your clipboardstatic func getCurrentPointsOfInterest(_ closure: @escaping ([PointOfInterest]) -> Void)
Example
Copied to your clipboardPlaces.getCurrentPointsOfInterest() { currentPois inprint("currentPois: (currentPois)")}
Objective-C
Syntax
Copied to your clipboard+ (void) getCurrentPointsOfInterest: ^(NSArray<AEPPlacesPoi*>* _Nonnull pois) closure;
Example
Copied to your clipboard[AEPMobilePlaces getCurrentPointsOfInterest:^(NSArray<AEPPlacesPoi *> *pois) {NSLog(@"currentPois: %@", pois);}];
Java
Example
Copied to your clipboardPlaces.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {@Overridepublic void call(List<PlacesPOI> pois) {// use the obtained POIs that the device is withinprocessUserWithinPois(pois);}});
Kotlin
Example
Copied to your clipboardPlaces.getCurrentPointsOfInterest() { pois ->// use the obtained POIs that the device is withinprocessUserWithinPois(pois)}
Swift
Syntax
Copied to your clipboardstatic func getCurrentPointsOfInterest(_ closure: @escaping ([PointOfInterest]) -> Void)
Example
Copied to your clipboardPlaces.getCurrentPointsOfInterest() { currentPois inprint("currentPois: (currentPois)")}
Objective-C
Syntax
Copied to your clipboard+ (void) getCurrentPointsOfInterest: ^(NSArray<AEPPlacesPoi*>* _Nonnull pois) closure;
Example
Copied to your clipboard[AEPMobilePlaces getCurrentPointsOfInterest:^(NSArray<AEPPlacesPoi *> *pois) {NSLog(@"currentPois: %@", pois);}];
getLastKnownLocation
Returns the last latitude and longitude provided to the AEPPlaces Extension.
If the Places Extension does not have a valid last known location for the user, the parameter passed in the closure will be nil
. The CLLocation
object returned by this method will only contain a valid coordinate. Other properties on the CLLocation
object should not be considered valid.
Java
Example
Copied to your clipboardPlaces.getLastKnownLocation(new AdobeCallback<Location>() {@Overridepublic void call(Location lastLocation) {// do something with the last known locationprocessLastKnownLocation(lastLocation);}});
Kotlin
Example
Copied to your clipboardPlaces.getLastKnownLocation() { lastLocation ->// do something with the last known locationprocessLastKnownLocation(lastLocation)}
Swift
Syntax
Copied to your clipboardstatic func getLastKnownLocation(_ closure: @escaping (CLLocation?) -> Void)
Example
Copied to your clipboardPlaces.getLastKnownLocation() { location inif let location = location {print("location returned from closure: ((location.coordinate.latitude), (location.coordinate.longitude))")}}
Objective-C
Syntax
Copied to your clipboard+ (void) getLastKnownLocation: ^(CLLocation* _Nullable lastLocation) closure;
Example
Copied to your clipboard[AEPMobilePlaces getLastKnownLocation:^(CLLocation *location) {if (location) {NSLog(@"location returned from closure: (%f, %f)", location.coordinate.latitude, location.coordinate.longitude);}}];
Java
Example
Copied to your clipboardPlaces.getLastKnownLocation(new AdobeCallback<Location>() {@Overridepublic void call(Location lastLocation) {// do something with the last known locationprocessLastKnownLocation(lastLocation);}});
Kotlin
Example
Copied to your clipboardPlaces.getLastKnownLocation() { lastLocation ->// do something with the last known locationprocessLastKnownLocation(lastLocation)}
Swift
Syntax
Copied to your clipboardstatic func getLastKnownLocation(_ closure: @escaping (CLLocation?) -> Void)
Example
Copied to your clipboardPlaces.getLastKnownLocation() { location inif let location = location {print("location returned from closure: ((location.coordinate.latitude), (location.coordinate.longitude))")}}
Objective-C
Syntax
Copied to your clipboard+ (void) getLastKnownLocation: ^(CLLocation* _Nullable lastLocation) closure;
Example
Copied to your clipboard[AEPMobilePlaces getLastKnownLocation:^(CLLocation *location) {if (location) {NSLog(@"location returned from closure: (%f, %f)", location.coordinate.latitude, location.coordinate.longitude);}}];
getNearbyPointsOfInterest
Requests a list of nearby Points of Interest (POI) and returns them in a closure.
Java
Syntax
Copied to your clipboardpublic static void getNearbyPointsOfInterest(@NonNull final Location location,final int limit,@NonNull final AdobeCallback<List<PlacesPOI>> successCallback,@NonNull final AdobeCallback<PlacesRequestError> errorCallback);
Example
Copied to your clipboardPlaces.getNearbyPointsOfInterest(currentLocation, 10,new AdobeCallback<List<PlacesPOI>>() {@Overridepublic void call(List<PlacesPOI> pois) {// do required processing with the returned nearbyPoi arraystartMonitoringPois(pois);}}, new AdobeCallback<PlacesRequestError>() {@Overridepublic void call(PlacesRequestError placesRequestError) {// look for the placesRequestError and handle the error accordinglyhandleError(placesRequestError);}});
Kotlin
Example
Copied to your clipboardPlaces.getNearbyPointsOfInterest(currentLocation, 10, { pois ->// do required processing with the returned nearbyPoi arraystartMonitoringPois(pois);}, { error ->// look for the placesRequestError and handle the error accordinglyhandleError(placesRequestError);})
Swift
Syntax
Copied to your clipboardstatic func getNearbyPointsOfInterest(forLocation location: CLLocation,withLimit limit: UInt,closure: @escaping ([PointOfInterest], PlacesQueryResponseCode) -> Void)
Example
Copied to your clipboardlet location = CLLocation(latitude: 40.4350229, longitude: -111.8918356)Places.getNearbyPointsOfInterest(forLocation: location, withLimit: 10) { (nearbyPois, responseCode) inprint("responseCode: (responseCode.rawValue) - nearbyPois: (nearbyPois)")}
Objective-C
Syntax
Copied to your clipboard+ (void) getNearbyPointsOfInterest: (nonnull CLLocation*) currentLocationlimit: (NSUInteger) limitcallback: ^ (NSArray<AEPPlacesPoi*>* _Nonnull, AEPPlacesQueryResponseCode) closure;
Example
Copied to your clipboardCLLocation *location = [[CLLocation alloc] initWithLatitude:40.4350229 longitude:-111.8918356];[AEPMobilePlaces getNearbyPointsOfInterest:locationlimit:10callback:^(NSArray<AEPPlacesPoi *> *pois, AEPPlacesQueryResponseCode responseCode) {NSLog(@"responseCode: %ld", (long)responseCode);NSLog(@"nearbyPois: %@", pois);}];
Java
Syntax
Copied to your clipboardpublic static void getNearbyPointsOfInterest(@NonNull final Location location,final int limit,@NonNull final AdobeCallback<List<PlacesPOI>> successCallback,@NonNull final AdobeCallback<PlacesRequestError> errorCallback);
Example
Copied to your clipboardPlaces.getNearbyPointsOfInterest(currentLocation, 10,new AdobeCallback<List<PlacesPOI>>() {@Overridepublic void call(List<PlacesPOI> pois) {// do required processing with the returned nearbyPoi arraystartMonitoringPois(pois);}}, new AdobeCallback<PlacesRequestError>() {@Overridepublic void call(PlacesRequestError placesRequestError) {// look for the placesRequestError and handle the error accordinglyhandleError(placesRequestError);}});
Kotlin
Example
Copied to your clipboardPlaces.getNearbyPointsOfInterest(currentLocation, 10, { pois ->// do required processing with the returned nearbyPoi arraystartMonitoringPois(pois);}, { error ->// look for the placesRequestError and handle the error accordinglyhandleError(placesRequestError);})
Swift
Syntax
Copied to your clipboardstatic func getNearbyPointsOfInterest(forLocation location: CLLocation,withLimit limit: UInt,closure: @escaping ([PointOfInterest], PlacesQueryResponseCode) -> Void)
Example
Copied to your clipboardlet location = CLLocation(latitude: 40.4350229, longitude: -111.8918356)Places.getNearbyPointsOfInterest(forLocation: location, withLimit: 10) { (nearbyPois, responseCode) inprint("responseCode: (responseCode.rawValue) - nearbyPois: (nearbyPois)")}
Objective-C
Syntax
Copied to your clipboard+ (void) getNearbyPointsOfInterest: (nonnull CLLocation*) currentLocationlimit: (NSUInteger) limitcallback: ^ (NSArray<AEPPlacesPoi*>* _Nonnull, AEPPlacesQueryResponseCode) closure;
Example
Copied to your clipboardCLLocation *location = [[CLLocation alloc] initWithLatitude:40.4350229 longitude:-111.8918356];[AEPMobilePlaces getNearbyPointsOfInterest:locationlimit:10callback:^(NSArray<AEPPlacesPoi *> *pois, AEPPlacesQueryResponseCode responseCode) {NSLog(@"responseCode: %ld", (long)responseCode);NSLog(@"nearbyPois: %@", pois);}];
processGeofence
When a device crosses one of your app's pre-defined Places Service region boundaries, the region and event type are passed to the SDK for processing.
Process a Geofence region event for the provided transitionType.
You can pass the transitionType from GeofencingEvent.getGeofenceTransition()
. Currently Geofence.GEOFENCE_TRANSITION_ENTER
and Geofence.GEOFENCE_TRANSITION_EXIT
are supported.
Android
Java
Syntax
Copied to your clipboardpublic static void processGeofence(final Geofence geofence, final int transitionType);
Example
Copied to your clipboardpublic class GeofenceTransitionsIntentService extends IntentService {public GeofenceTransitionsIntentService() {super("GeofenceTransitionsIntentService");}protected void onHandleIntent(Intent intent) {GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);List<Geofence> geofences = geofencingEvent.getTriggeringGeofences();if (geofences.size() > 0) {// Call the Places API to process informationPlaces.processGeofence(geofences.get(0), geofencingEvent.getGeofenceTransition());}}}
Kotlin
Example
Copied to your clipboardfun onHandleIntent(intent: Intent) {val geofencingEvent = GeofencingEvent.fromIntent(intent)val geofences = geofencingEvent.getTriggeringGeofences()if (!geofences.isEmpty()) {Places.processGeofence(geofences.first(), geofencingEvent.getGeofenceTransition())}}
Java
Syntax
Copied to your clipboardpublic static void processGeofence(final Geofence geofence, final int transitionType);
Example
Copied to your clipboardpublic class GeofenceTransitionsIntentService extends IntentService {public GeofenceTransitionsIntentService() {super("GeofenceTransitionsIntentService");}protected void onHandleIntent(Intent intent) {GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);List<Geofence> geofences = geofencingEvent.getTriggeringGeofences();if (geofences.size() > 0) {// Call the Places API to process informationPlaces.processGeofence(geofences.get(0), geofencingEvent.getGeofenceTransition());}}}
Kotlin
Example
Copied to your clipboardfun onHandleIntent(intent: Intent) {val geofencingEvent = GeofencingEvent.fromIntent(intent)val geofences = geofencingEvent.getTriggeringGeofences()if (!geofences.isEmpty()) {Places.processGeofence(geofences.first(), geofencingEvent.getGeofenceTransition())}}
processGeofenceEvent
Process all Geofences in the GeofencingEvent at the same time.
Android
Java
Syntax
Copied to your clipboardpublic static void processGeofenceEvent(@NonNull final GeofencingEvent geofencingEvent);
Example
Copied to your clipboardpublic class GeofenceTransitionsIntentService extends IntentService {public GeofenceTransitionsIntentService() {super("GeofenceTransitionsIntentService");}protected void onHandleIntent(Intent intent) {GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);// Call the Places API to process informationPlaces.processGeofenceEvent(geofencingEvent);}}
Kotlin
Example
Copied to your clipboardfun onHandleIntent(intent: Intent) {val geofencingEvent = GeofencingEvent.fromIntent(intent)// Call the Places API to process informationPlaces.processGeofenceEvent(geofencingEvent)}
Java
Syntax
Copied to your clipboardpublic static void processGeofenceEvent(@NonNull final GeofencingEvent geofencingEvent);
Example
Copied to your clipboardpublic class GeofenceTransitionsIntentService extends IntentService {public GeofenceTransitionsIntentService() {super("GeofenceTransitionsIntentService");}protected void onHandleIntent(Intent intent) {GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);// Call the Places API to process informationPlaces.processGeofenceEvent(geofencingEvent);}}
Kotlin
Example
Copied to your clipboardfun onHandleIntent(intent: Intent) {val geofencingEvent = GeofencingEvent.fromIntent(intent)// Call the Places API to process informationPlaces.processGeofenceEvent(geofencingEvent)}
processRegionEvent
Passes a CLRegion
and a PlacesRegionEvent
to be processed by the Places extension.
Calling this method will result in an Event
being dispatched to the SDK's EventHub
. This enables rule processing based on the triggering region event.
iOS
Swift
Syntax
Copied to your clipboardstatic func processRegionEvent(_ regionEvent: PlacesRegionEvent,forRegion region: CLRegion)
Example
Copied to your clipboardlet region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: 40.3886845, longitude: -111.8284979),radius: 100,identifier: "877677e4-3004-46dd-a8b1-a609bd65a428")Places.processRegionEvent(.entry, forRegion: region)
Objective-C
Syntax
Copied to your clipboard+ (void) processRegionEvent: (AEPRegionEventType) eventTypeforRegion: (nonnull CLRegion*) region;
Example
Copied to your clipboardCLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(40.3886845, -111.8284979)radius:100identifier:@"877677e4-3004-46dd-a8b1-a609bd65a428"];[AEPMobilePlaces processRegionEvent:AEPPlacesRegionEventEntry forRegion:region];
Swift
Syntax
Copied to your clipboardstatic func processRegionEvent(_ regionEvent: PlacesRegionEvent,forRegion region: CLRegion)
Example
Copied to your clipboardlet region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: 40.3886845, longitude: -111.8284979),radius: 100,identifier: "877677e4-3004-46dd-a8b1-a609bd65a428")Places.processRegionEvent(.entry, forRegion: region)
Objective-C
Syntax
Copied to your clipboard+ (void) processRegionEvent: (AEPRegionEventType) eventTypeforRegion: (nonnull CLRegion*) region;
Example
Copied to your clipboardCLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(40.3886845, -111.8284979)radius:100identifier:@"877677e4-3004-46dd-a8b1-a609bd65a428"];[AEPMobilePlaces processRegionEvent:AEPPlacesRegionEventEntry forRegion:region];
registerExtension
This API has been deprecated starting in v2.0.0 and removed in v3.0.0 of the Android mobile extension.
Use MobileCore.registerExtensions()
API instead.
setAccuracyAuthorization
Sets the accuracy authorization status in the Places extension.
The value provided is stored in the Places shared state, and is for reference only. Calling this method does not impact the actual location accuracy authorization for this device.
iOS
Swift
Syntax
Copied to your clipboardstatic func setAccuracyAuthorization(_ accuracy: CLAccuracyAuthorization)
Example
Copied to your clipboardPlaces.setAccuracyAuthorization(.fullAccuracy)
Objective-C
Syntax
Copied to your clipboard+ (void) setAccuracyAuthorization: (CLAccuracyAuthorization) accuracy;
Example
Copied to your clipboard[AEPMobilePlaces setAccuracyAuthorization:CLAccuracyAuthorizationFullAccuracy];
Swift
Syntax
Copied to your clipboardstatic func setAccuracyAuthorization(_ accuracy: CLAccuracyAuthorization)
Example
Copied to your clipboardPlaces.setAccuracyAuthorization(.fullAccuracy)
Objective-C
Syntax
Copied to your clipboard+ (void) setAccuracyAuthorization: (CLAccuracyAuthorization) accuracy;
Example
Copied to your clipboard[AEPMobilePlaces setAccuracyAuthorization:CLAccuracyAuthorizationFullAccuracy];
setAuthorizationStatus
Sets the authorization status in the Places extension.
The status provided is stored in the Places shared state, and is for reference only. Calling this method does not impact the actual location authorization status for this device.
This method should only be called from the CLLocationManagerDelegate
protocol method locationManagerDidChangeAuthorization(_:).
Java
Syntax
Copied to your clipboardpublic static void setAuthorizationStatus(final PlacesAuthorizationStatus status);
Example
Copied to your clipboardPlaces.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS);
Kotlin
Example
Copied to your clipboardPlaces.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS)
Swift
Syntax
Copied to your clipboardstatic func setAuthorizationStatus(status: CLAuthorizationStatus)
Example
Copied to your clipboard// in the class implementing CLLocationManagerDelegate:func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {Places.setAuthorizationStatus(status: manager.authorizationStatus)}
Objective-C
Syntax
Copied to your clipboard+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
Example
Copied to your clipboard// in the class implementing CLLocationManagerDelegate:- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager {[AEPMobilePlaces setAuthorizationStatus:manager.authorizationStatus];}
Java
Syntax
Copied to your clipboardpublic static void setAuthorizationStatus(final PlacesAuthorizationStatus status);
Example
Copied to your clipboardPlaces.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS);
Kotlin
Example
Copied to your clipboardPlaces.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS)
Swift
Syntax
Copied to your clipboardstatic func setAuthorizationStatus(status: CLAuthorizationStatus)
Example
Copied to your clipboard// in the class implementing CLLocationManagerDelegate:func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {Places.setAuthorizationStatus(status: manager.authorizationStatus)}
Objective-C
Syntax
Copied to your clipboard+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
Example
Copied to your clipboard// in the class implementing CLLocationManagerDelegate:- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager {[AEPMobilePlaces setAuthorizationStatus:manager.authorizationStatus];}
Additional classes and enums
Type | Swift | Objective-C |
---|---|---|
class | PointOfInterest | AEPPlacesPoi |
enum | PlacesQueryResponseCode | AEPlacesQueryResponseCode |
enum | PlacesRegionEvent | AEPPlacesRegionEvent |
PointOfInterest
Name | Data Type |
---|---|
identifier | String |
latitude | Double |
libraryId | String |
longitude | Double |
metaData | [String: String] |
name | String |
radius | Int |
userIsWithin | Bool |
weight | Int |
PlacesQueryResponseCode
Case | Raw Value |
---|---|
ok | 0 |
connectivityError | 1 |
serverResponseError | 2 |
invalidLatLongError | 3 |
configurationError | 4 |
queryServiceUnavailable | 5 |
privacyOptedOut | 6 |
unknownError | 7 |
PlacesRegionEvent
Case | Raw Value |
---|---|
entry | 0 |
exit | 1 |