Places拡張機能のAPIリファレンスに関する情報を次に示します。
デバイスがアプリの事前定義済みの場所サービスの領域の境界の1つを越えると、領域とイベントタイプがSDKに渡され、処理されます。
指定されたtransitionType
のGeofence
リージョンイベントを処理します。
GeofencingEvent.getGeofenceTransition()
からtransitionType
を渡します。 現在、Geofence.GEOFENCE_TRANSITION_ENTER
とGeofence.GEOFENCE_TRANSITION_EXIT
がサポートされています。
構文
このメソッドの構文を次に示します。
public static void processGeofence(final Geofence geofence, final int transitionType);
例
Android Geofenceイベントの受信用に登録されているIntentService
で、このメソッドを呼び出します。
このメソッドのコードサンプルを次に示します。
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());
}
}
}
このメソッドは、CLLocationManager
デリゲートで呼び出す必要があります。これは、ユーザーが特定の領域に入ったか出たかを示します。
構文
このメソッドの構文を次に示します。
+ (void) processRegionEvent: (nonnull CLRegion*) region forRegionEventType: (ACPRegionEventType) eventType;
例
このメソッドのコードサンプルを次に示します。
- (void) locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[ACPPlaces processRegionEvent:region forRegionEventType:ACPRegionEventTypeEntry];
}
- (void) locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[ACPPlaces processRegionEvent:region forRegionEventType:ACPRegionEventTypeExit];
}
GeofencingEvent
内のすべてのGeofences
を同時に処理します。
構文
public static void processGeofenceEvent(final GeofencingEvent geofencingEvent);
例
Android Geofenceイベントの受信に登録されているIntentService
で、このメソッドを呼び出します。
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);
}
}
コールバックで、隣接するPOIの順序付けられたリストを返します。 このメソッドのオーバーロードされたバージョンは、結果のネットワーク呼び出しで何か問題が発生した場合にエラーコードを返します。
このメソッドの構文を次に示します。
構文
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);
例
このメソッドのコードサンプルを次に示します。
// 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);
}
}
);
構文
+ (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;
例
// 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];
}
];
デバイスが現在存在することがわかっているPOIのリストを要求し、コールバックで返します。
このメソッドの構文を次に示します。
構文
public static void getCurrentPointsOfInterest(final AdobeCallback<List<PlacesPOI>> callback);
例
このメソッドのコードサンプルを次に示します。
Places.getCurrentPointsOfInterest(new AdobeCallback<List<PlacesPOI>>() {
@Override
public void call(List<PlacesPOI> pois) {
// use the obtained POIs that the device is within
processUserWithinPois(pois);
}
});
構文
このメソッドの構文を次に示します。
+ (void) getCurrentPointsOfInterest: (nullable void (^) (NSArray<ACPPlacesPoi*>* _Nullable userWithinPoi)) callback;
例
このメソッドのコードサンプルを次に示します。
[ACPPlaces getCurrentPointsOfInterest:^(NSArray<ACPPlacesPoi*>* userWithinPoi) {
// do required processing with the returned userWithinPoi array
[self processUserWithinPois:userWithinPoi];
}];
Places拡張機能によって、既知のデバイスの場所を要求します。
Places拡張機能は、GetNearbyPointsOfInterest
への呼び出しによって提供された場所についてのみ知っています。
構文
このメソッドの構文を次に示します。
public static void getLastKnownLocation(final AdobeCallback<Location> callback);
例
このメソッドのコードサンプルを次に示します。
Places.getLastKnownLocation(new AdobeCallback<Location>() {
@Override
public void call(Location lastLocation) {
// do something with the last known location
processLastKnownLocation(lastLocation);
}
});
構文
このメソッドの構文を次に示します。
+ (void) getLastKnownLocation: (nullable void (^) (CLLocation* _Nullable lastLocation)) callback;
例
このメソッドのコードサンプルを次に示します。
[ACPPlaces getLastKnownLocation:^(CLLocation* lastLocation) {
// do something with the last known location
[self processLastKnownLocation:lastLocation];
}];
共有状態、ローカルストレージ、およびメモリ内のPlaces拡張のクライアント側データを消去します。
構文
このメソッドの構文を次に示します。
public static void clear();
例
このメソッドのコードサンプルを次に示します。
Places.clear();
共有状態、ローカルストレージ、およびメモリ内のPlaces拡張のクライアント側データを消去します。
構文
このメソッドの構文を次に示します。
+ (void) clear;
例
このメソッドのコードサンプルを次に示します。
[ACPPlaces clear];
Places v1.4.0以降で利用可能
Places拡張で認証状態を設定します。
表示されるステータスは、[場所]共有状態に保存され、参照用にのみ表示されます。
このメソッドを呼び出しても、このデバイスの実際の場所の認証状態には影響しません。
構文
このメソッドの構文を次に示します。
public static void setAuthorizationStatus(final PlacesAuthorizationStatus status);
例
このメソッドのコードサンプルを次に示します。
Places.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS);
ACPPlaces v1.3.0以降で利用可能
Places拡張で認証状態を設定します。
表示されるステータスは、[場所]共有状態に保存され、参照用にのみ表示されます。
このメソッドを呼び出しても、このデバイスの実際の場所の認証状態には影響しません。
デバイス認証の状態が変わると、CLLocationManagerDelegate
のlocationManager:didChangeAuthorizationStatus:
メソッドが呼び出されます。 このメソッド内から、新しいCLAuthorizationStatus
値をACPPlaces setAuthorizationStatus:
APIに渡す必要があります。
構文
このメソッドの構文を次に示します。
+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
例
このメソッドのコードサンプルを次に示します。
- (void) locationManager: (CLLocationManager*) manager didChangeAuthorizationStatus: (CLAuthorizationStatus) status {
[ACPPlaces setAuthorizationStatus:status];
}