Informazioni sui riferimenti API nell'estensione Luoghi:
Quando un dispositivo attraversa uno dei limiti dell'area del servizio Luoghi predefinita dell'app, l'area e il tipo di evento vengono passati all'SDK per l'elaborazione.
Elabora un evento Geofence
regionale per il contenuto fornito transitionType
.
Passate la transitionType
da GeofencingEvent.getGeofenceTransition()
. Attualmente Geofence.GEOFENCE_TRANSITION_ENTER
e Geofence.GEOFENCE_TRANSITION_EXIT
sono supportati.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
public static void processGeofence(final Geofence geofence, final int transitionType);
Esempio
Chiama questo metodo nel tuo account IntentService
registrato per ricevere eventi di geofence Android.
Di seguito è riportato un esempio di codice per questo metodo:
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());
}
}
}
Questo metodo deve essere chiamato nel CLLocationManager
delegato, che indica se l’utente è entrato o uscito da una regione specifica.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
+ (void) processRegionEvent: (nonnull CLRegion*) region forRegionEventType: (ACPRegionEventType) eventType;
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[ACPPlaces processRegionEvent:region forRegionEventType:ACPRegionEventTypeEntry];
}
- (void) locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[ACPPlaces processRegionEvent:region forRegionEventType:ACPRegionEventTypeExit];
}
Elabora tutti Geofences
allo GeofencingEvent
stesso tempo.
Sintassi
public static void processGeofenceEvent(final GeofencingEvent geofencingEvent);
Esempio
Chiama questo metodo nel tuo IntentService
che è registrato per ricevere eventi di geofence 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);
}
}
Restituisce un elenco ordinato di POI vicini in un callback. Una versione sovraccaricata di questo metodo restituisce un codice di errore se si è verificato un errore con la chiamata di rete risultante.
Di seguito è riportata la sintassi per questo metodo:
Sintassi
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);
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
// 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);
}
}
);
Sintassi
+ (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;
Esempio
// 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];
}
];
Richiede un elenco di POI in cui è attualmente noto che il dispositivo si trova e li restituisce in una callback.
Di seguito è riportata la sintassi per questo metodo:
Sintassi
public static void getCurrentPointsOfInterest(final AdobeCallback<List<PlacesPOI>> callback);
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
Places.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {
@Override
public void call(List<PlacesPOI> pois) {
// use the obtained POIs that the device is within
processUserWithinPois(pois);
}
});
Sintassi
Di seguito è riportata la sintassi per questo metodo:
+ (void) getCurrentPointsOfInterest: (nullable void (^) (NSArray<ACPPlacesPoi*>* _Nullable userWithinPoi)) callback;
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
[ACPPlaces getCurrentPointsOfInterest:^(NSArray<ACPPlacesPoi*>* userWithinPoi) {
// do required processing with the returned userWithinPoi array
[self processUserWithinPois:userWithinPoi];
}];
Richiede la posizione del dispositivo, come precedentemente noto, dall'estensione Luoghi.
L'estensione Luoghi è a conoscenza solo delle posizioni che gli sono state fornite tramite chiamate a GetNearbyPointsOfInterest
.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
public static void getLastKnownLocation(final AdobeCallback<Location> callback);
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
Places.getLastKnownLocation(new AdobeCallback<Location>() {
@Override
public void call(Location lastLocation) {
// do something with the last known location
processLastKnownLocation(lastLocation);
}
});
Sintassi
Di seguito è riportata la sintassi per questo metodo:
+ (void) getLastKnownLocation: (nullable void (^) (CLLocation* _Nullable lastLocation)) callback;
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
[ACPPlaces getLastKnownLocation:^(CLLocation* lastLocation) {
// do something with the last known location
[self processLastKnownLocation:lastLocation];
}];
Elimina i dati lato client per l'estensione Luoghi nello stato condiviso, nella memorizzazione locale e nella memoria.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
public static void clear();
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
Places.clear();
Elimina i dati lato client per l'estensione Luoghi in stato condiviso, archiviazione locale e memoria.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
+ (void) clear;
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
[ACPPlaces clear];
Disponibile a partire da Places v1.4.0
Imposta lo stato dell'autorizzazione nell'estensione Luoghi.
Lo stato fornito è memorizzato nello stato Condiviso Luoghi e lo è solo per riferimento.
La chiamata di questo metodo non influisce sullo stato effettivo dell'autorizzazione di posizione per il dispositivo.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
public static void setAuthorizationStatus(final PlacesAuthorizationStatus status);
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
Places.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS);
Disponibile a partire da ACPPlaces v1.3.0
Imposta lo stato dell'autorizzazione nell'estensione Luoghi.
Lo stato fornito è memorizzato nello stato Condiviso Luoghi e lo è solo per riferimento.
La chiamata di questo metodo non influisce sullo stato effettivo dell'autorizzazione di posizione per il dispositivo.
Quando lo stato dell'autorizzazione del dispositivo cambia, viene richiamato il locationManager:didChangeAuthorizationStatus:
metodo del CLLocationManagerDelegate
dispositivo. Dall'interno di questo metodo, è necessario trasmettere il nuovo CLAuthorizationStatus
valore all' setAuthorizationStatus:
API ACPPlaces.
Sintassi
Di seguito è riportata la sintassi per questo metodo:
+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
Esempio
Di seguito è riportato un esempio di codice per questo metodo:
- (void) locationManager: (CLLocationManager*) manager didChangeAuthorizationStatus: (CLAuthorizationStatus) status {
[ACPPlaces setAuthorizationStatus:status];
}