Place la référence API

Voici des informations sur les références d'API dans l'extension Places :

Traitement d’un événement de région

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.

ProcessGeofence (Android)

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());
        }
    }
}

ProcessRegionEvent (iOS)

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];
}

ProcessGeofencingEvent (Android)

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);
    }
}

Récupérer les points d'intérêt voisins

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.

GetNearbyPointsOfInterest (Android)

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);
        }
    }
);

GetNearbyPointsOfInterest (iOS)

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];
    }
];

Récupérer les points ciblés actuels du périphérique

Demande une liste de points d’intérêt dans lesquels le périphérique est actuellement connu et les renvoie dans un rappel.

GetCurrentPointsOfInterest (Android)

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);
    }
});

GetCurrentPointsOfInterest (iOS)

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];
}];

Obtenir l'emplacement du périphérique

Demande l’emplacement du périphérique, comme on l’a déjà appelé, par l’extension Places.

CONSEIL

L'extension Places ne connaît que les emplacements qui lui ont été fournis via des appels à GetNearbyPointsOfInterest.

GetLastKnownLocation (Android)

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);
    }
});

GetLastKnownLocation (iOS)

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];
}];

Effacer les données côté client

Clear (Android)

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();

clear (iOS)

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];

Définir l'état d'autorisation de l'emplacement

setAuthorizationStatus (Android)

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);

setAuthorizationStatus (iOS)

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];
}

Sur cette page