Places API reference
This document contains usage information for the public functions, classes, and enums in AEPPlaces.

Static functions

clear

Clears out the client-side data for Places in shared state, local storage, and in-memory.
Swift
Objective-C
Syntax
1
static func clear()
Copied!
Example
1
Places.clear()
Copied!
Syntax
1
+ (void) clear;
Copied!
Example
1
[AEPMobilePlaces clear];
Copied!

extensionVersion

Returns the running version of the AEPPlaces extension.
Swift
Objective-C
Syntax
1
static var extensionVersion: String
Copied!
Example
1
let placesVersion = Places.extensionVersion
Copied!
Syntax
1
+ (nonnull NSString*) extensionVersion;
Copied!
Example
1
NSString *placesVersion = [AEPMobilePlaces extensionVersion];
Copied!

getCurrentPointsOfInterest

Returns all points of interest (POI) of which the device is currently known to be within.
Swift
Objective-C
Syntax
1
static func getCurrentPointsOfInterest(_ closure: @escaping ([PointOfInterest]) -> Void)
Copied!
Example
1
Places.getCurrentPointsOfInterest() { currentPois in
2
print("currentPois: (currentPois)")
3
}
Copied!
Syntax
1
+ (void) getCurrentPointsOfInterest: ^(NSArray<AEPPlacesPoi*>* _Nonnull pois) closure;
Copied!
Example
1
[AEPMobilePlaces getCurrentPointsOfInterest:^(NSArray<AEPPlacesPoi *> *pois) {
2
NSLog(@"currentPois: %@", pois);
3
}];
Copied!

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.
Swift
Objective-C
Syntax
1
static func getLastKnownLocation(_ closure: @escaping (CLLocation?) -> Void)
Copied!
Example
1
Places.getLastKnownLocation() { location in
2
if let location = location {
3
print("location returned from closure: ((location.coordinate.latitude), (location.coordinate.longitude))")
4
}
5
}
Copied!
Syntax
1
+ (void) getLastKnownLocation: ^(CLLocation* _Nullable lastLocation) closure;
Copied!
Example
1
[AEPMobilePlaces getLastKnownLocation:^(CLLocation *location) {
2
if (location) {
3
NSLog(@"location returned from closure: (%f, %f)", location.coordinate.latitude, location.coordinate.longitude);
4
}
5
}];
Copied!

getNearbyPointsOfInterest

Requests a list of nearby Points of Interest (POI) and returns them in a closure.
Swift
Objective-C
Syntax
1
static func getNearbyPointsOfInterest(forLocation location: CLLocation,
2
withLimit limit: UInt,
3
closure: @escaping ([PointOfInterest], PlacesQueryResponseCode) -> Void)
Copied!
Example
1
let location = CLLocation(latitude: 40.4350229, longitude: -111.8918356)
2
Places.getNearbyPointsOfInterest(forLocation: location, withLimit: 10) { (nearbyPois, responseCode) in
3
print("responseCode: (responseCode.rawValue) - nearbyPois: (nearbyPois)")
4
}
Copied!
Syntax
1
+ (void) getNearbyPointsOfInterest: (nonnull CLLocation*) currentLocation
2
limit: (NSUInteger) limit
3
callback: ^ (NSArray<AEPPlacesPoi*>* _Nonnull, AEPPlacesQueryResponseCode) closure;
Copied!
Example
1
CLLocation *location = [[CLLocation alloc] initWithLatitude:40.4350229 longitude:-111.8918356];
2
3
[AEPMobilePlaces getNearbyPointsOfInterest:location
4
limit:10
5
callback:^(NSArray<AEPPlacesPoi *> *pois, AEPPlacesQueryResponseCode responseCode) {
6
NSLog(@"responseCode: %ld", (long)responseCode);
7
NSLog(@"nearbyPois: %@", pois);
8
}];
Copied!

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.
Swift
Objective-C
Syntax
1
static func processRegionEvent(_ regionEvent: PlacesRegionEvent,
2
forRegion region: CLRegion)
Copied!
Example
1
let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: 40.3886845, longitude: -111.8284979),
2
radius: 100,
3
identifier: "877677e4-3004-46dd-a8b1-a609bd65a428")
4
5
Places.processRegionEvent(.entry, forRegion: region)
Copied!
Syntax
1
+ (void) processRegionEvent: (AEPRegionEventType) eventType
2
forRegion: (nonnull CLRegion*) region;
Copied!
Example
1
CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(40.3886845, -111.8284979)
2
radius:100
3
identifier:@"877677e4-3004-46dd-a8b1-a609bd65a428"];
4
5
[AEPMobilePlaces processRegionEvent:AEPPlacesRegionEventEntry forRegion:region];
Copied!

registerExtension

This API no longer exists in AEPPlaces. Instead, the extension should be registered by calling the registerExtensions API in the MobileCore.
Swift
Objective-C
Example:
1
MobileCore.registerExtensions([Places.self])
Copied!
Example:
1
[AEPMobileCore registerExtensions:@[AEPMobilePlaces.class] completion:nil];
Copied!

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.
Untitled
Untitled
Untitled
Untitled
Untitled
Untitled
Untitled
Untitled
Untitled
Untitled
{% tab title="Swift"}
Syntax
1
static func setAccuracyAuthorization(_ accuracy: CLAccuracyAuthorization)
Copied!
Example
1
Places.setAccuracyAuthorization(.fullAccuracy)
Copied!
{% tab title="Objective-C"}
Syntax
1
+ (void) setAccuracyAuthorization: (CLAccuracyAuthorization) accuracy;
Copied!
Example
1
[AEPMobilePlaces setAccuracyAuthorization:CLAccuracyAuthorizationFullAccuracy];
Copied!

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(_:).
Swift
Objective-C
Syntax
1
static func setAuthorizationStatus(status: CLAuthorizationStatus)
Copied!
Example
1
// in the class implementing CLLocationManagerDelegate:
2
3
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
4
Places.setAuthorizationStatus(status: manager.authorizationStatus)
5
}
Copied!
Syntax
1
+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
Copied!
Example
1
// in the class implementing CLLocationManagerDelegate:
2
3
- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager {
4
[AEPMobilePlaces setAuthorizationStatus:manager.authorizationStatus];
5
}
Copied!

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
Last modified 3mo ago