Voici des informations sur les références d'API dans l'extension Places :
Lorsqu’un appareil dépasse l’une des limites de la région du service Places prédéfinies de votre application, la région et le type d'événement sont transmis au SDK pour traitement.
Traitez un événement de région Geofence
pour le transitionType
fourni.
Transférez transitionType
de GeofencingEvent.getGeofenceTransition()
. Actuellement, Geofence.GEOFENCE_TRANSITION_ENTER
et Geofence.GEOFENCE_TRANSITION_EXIT
sont pris en charge.
Syntaxe
Voici la syntaxe de cette méthode :
public static void processGeofence(final Geofence geofence, final int transitionType);
Exemple
Appelez cette méthode dans votre IntentService
qui est enregistrée pour la réception de événements de géofence Android.
Voici un exemple de code pour cette méthode :
public 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 information
Places.processGeofence(geofences.get(0), geofencingEvent.getGeofenceTransition());
}
}
}
Cette méthode doit être appelée dans le délégué CLLocationManager
, qui indique si l'utilisateur est entré dans une région spécifique ou s'il en est sorti.
Syntaxe
Voici la syntaxe de cette méthode :
+ (void) processRegionEvent: (nonnull CLRegion*) region forRegionEventType: (ACPRegionEventType) eventType;
Exemple
Voici l’exemple de code pour cette méthode :
- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[ACPPlaces processRegionEvent:region forRegionEventType:ACPRegionEventTypeEntry];
}
- (void) locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[ACPPlaces processRegionEvent:region forRegionEventType:ACPRegionEventTypeExit];
}
Traitez simultanément tous les Geofences
dans GeofencingEvent
.
Syntaxe
public static void processGeofenceEvent(final GeofencingEvent geofencingEvent);
Exemple
Appelez cette méthode dans votre IntentService
qui est enregistrée pour la réception de événements de géofence Android.
public class GeofenceTransitionsIntentService extends IntentService {
public GeofenceTransitionsIntentService() {
super("GeofenceTransitionsIntentService");
}
protected void onHandleIntent(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
// Call the Places API to process information
Places.processGeofenceEvent(geofencingEvent);
}
}
Renvoie une liste ordonnée des points d’intérêt voisins dans un rappel. Une version surchargée de cette méthode renvoie un code d'erreur si un problème s'est produit avec l'appel réseau résultant.
Voici la syntaxe de cette méthode :
Syntaxe
public static void getNearbyPointsOfInterest(final Location location, final int limit,
final AdobeCallback<List<PlacesPOI>> callback);
public static void getNearbyPointsOfInterest(final Location location, final int limit,
final AdobeCallback<List<PlacesPOI>> callback,
final AdobeCallback<PlacesRequestError> errorCallback);
Exemple
Voici l’exemple de code pour cette méthode :
// getNearbyPointsOfInterest without an error callback
Places.getNearbyPointsOfInterest(currentLocation, 10, new AdobeCallback<List<PlacesPOI>>() {
@Override
public void call(List<PlacesPOI> pois) {
// do required processing with the returned nearbyPoi array
startMonitoringPois(pois);
}
});
// getNearbyPointsOfInterest with an error callback
Places.getNearbyPointsOfInterest(currentLocation, 10,
new AdobeCallback<List<PlacesPOI>>() {
@Override
public void call(List<PlacesPOI> pois) {
// do required processing with the returned nearbyPoi array
startMonitoringPois(pois);
}
}, new AdobeCallback<PlacesRequestError>() {
@Override
public void call(PlacesRequestError placesRequestError) {
// look for the placesRequestError and handle the error accordingly
handleError(placesRequestError);
}
}
);
Syntaxe
+ (void) getNearbyPointsOfInterest: (nonnull CLLocation*) currentLocation
limit: (NSUInteger) limit
callback: (nullable void (^) (NSArray<ACPPlacesPoi*>* _Nullable nearbyPoi)) callback;
+ (void) getNearbyPointsOfInterest: (nonnull CLLocation*) currentLocation
limit: (NSUInteger) limit
callback: (nullable void (^) (NSArray<ACPPlacesPoi*>* _Nullable nearbyPoi)) callback
errorCallback: (nullable void (^) (ACPPlacesRequestError result)) errorCallback;
Exemple
// getNearbyPointsOfInterest without an error callback
[ACPPlaces getNearbyPointsOfInterest:location
limit:10
callback:^(NSArray<ACPPlacesPoi*>* nearbyPoi) {
// do required processing with the returned nearbyPoi array
[self startMonitoringPois:nearbyPOI];
}];
// getNearbyPointsOfInterest with an error callback
[ACPPlaces getNearbyPointsOfInterest:location limit:10
callback:^(NSArray<ACPPlacesPoi *> * _Nullable nearbyPoi) {
// do required processing with the returned nearbyPoi array
[self startMonitoringPois:nearbyPOI];
} errorCallback:^(ACPPlacesRequestError result) {
// look for the error and handle accordingly
[self handleError:result];
}
];
Demande une liste de points d’intérêt dans lesquels le périphérique est actuellement connu et les renvoie dans un rappel.
Voici la syntaxe de cette méthode :
Syntaxe
public static void getCurrentPointsOfInterest(final AdobeCallback<List<PlacesPOI>> callback);
Exemple
Voici l’exemple de code pour cette méthode :
Places.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {
@Override
public void call(List<PlacesPOI> pois) {
// use the obtained POIs that the device is within
processUserWithinPois(pois);
}
});
Syntaxe
Voici la syntaxe de cette méthode :
+ (void) getCurrentPointsOfInterest: (nullable void (^) (NSArray<ACPPlacesPoi*>* _Nullable userWithinPoi)) callback;
Exemple
Voici l’exemple de code pour cette méthode :
[ACPPlaces getCurrentPointsOfInterest:^(NSArray<ACPPlacesPoi*>* userWithinPoi) {
// do required processing with the returned userWithinPoi array
[self processUserWithinPois:userWithinPoi];
}];
Demande l’emplacement du périphérique, comme on l’a déjà appelé, par l’extension Places.
L'extension Places ne connaît que les emplacements qui lui ont été fournis via des appels à GetNearbyPointsOfInterest
.
Syntaxe
Voici la syntaxe de cette méthode :
public static void getLastKnownLocation(final AdobeCallback<Location> callback);
Exemple
Voici l’exemple de code pour cette méthode :
Places.getLastKnownLocation(new AdobeCallback<Location>() {
@Override
public void call(Location lastLocation) {
// do something with the last known location
processLastKnownLocation(lastLocation);
}
});
Syntaxe
Voici la syntaxe de cette méthode :
+ (void) getLastKnownLocation: (nullable void (^) (CLLocation* _Nullable lastLocation)) callback;
Exemple
Voici l’exemple de code pour cette méthode :
[ACPPlaces getLastKnownLocation:^(CLLocation* lastLocation) {
// do something with the last known location
[self processLastKnownLocation:lastLocation];
}];
Efface les données côté client pour l'extension Places dans l'état partagé, l'enregistrement local et en mémoire.
Syntaxe
Voici la syntaxe de cette méthode :
public static void clear();
Exemple
Voici l’exemple de code pour cette méthode :
Places.clear();
Efface les données côté client pour l'extension Places dans l'état partagé, l'enregistrement local et en mémoire.
Syntaxe
Voici la syntaxe de cette méthode :
+ (void) clear;
Exemple
Voici l’exemple de code pour cette méthode :
[ACPPlaces clear];
Disponible à partir de Places v1.4.0
Définit l’état d’autorisation dans l’extension Places.
L’état fourni est stocké dans l’état partagé Places et n’est utilisé que pour référence.
L'appel de cette méthode n'a aucune incidence sur l'état réel d'autorisation d'emplacement pour ce périphérique.
Syntaxe
Voici la syntaxe de cette méthode :
public static void setAuthorizationStatus(final PlacesAuthorizationStatus status);
Exemple
Voici l’exemple de code pour cette méthode :
Places.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS);
Disponible à partir de ACPPlaces v1.3.0
Définit l’état d’autorisation dans l’extension Places.
L’état fourni est stocké dans l’état partagé Places et n’est utilisé que pour référence.
L'appel de cette méthode n'a aucune incidence sur l'état réel d'autorisation d'emplacement pour ce périphérique.
Lorsque l'état d'autorisation du périphérique change, la méthode locationManager:didChangeAuthorizationStatus:
de votre CLLocationManagerDelegate
est appelée. Dans cette méthode, vous devez transmettre la nouvelle valeur CLAuthorizationStatus
à l'API ACPPlaces setAuthorizationStatus:
.
Syntaxe
Voici la syntaxe de cette méthode :
+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
Exemple
Voici l’exemple de code pour cette méthode :
- (void) locationManager: (CLLocationManager*) manager didChangeAuthorizationStatus: (CLAuthorizationStatus) status {
[ACPPlaces setAuthorizationStatus:status];
}