Places 拡張機能の API リファレンスに関する情報を次に示します。
デバイスがアプリの事前定義済みの Places Service 地域の境界を越えると、地域とイベントタイプが SDK に渡されて処理されます。
プロセス a Geofence
指定されたの地域イベント transitionType
.
パス transitionType
から GeofencingEvent.getGeofenceTransition()
. 現在 Geofence.GEOFENCE_TRANSITION_ENTER
および Geofence.GEOFENCE_TRANSITION_EXIT
はサポートされています。
構文
このメソッドの構文を次に示します。
public static void processGeofence(final Geofence geofence, final int transitionType);
例
このメソッドを IntentService
Android ジオフェンスイベントの受信用に登録されている
このメソッドのコードサンプルを次に示します。
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
delegate:ユーザーが特定の地域に入ったか出たかを示します。
構文
このメソッドの構文を次に示します。
+ (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];
}
すべてを処理 Geofences
内 GeofencingEvent
同時に
構文
public static void processGeofenceEvent(final GeofencingEvent geofencingEvent);
例
このメソッドを IntentService
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);
}
}
コールバックで近くの 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 拡張機能で認証ステータスを設定します。
提供されたステータスは「Places」共有状態に保存され、参照用にのみ表示されます。
このメソッドを呼び出しても、このデバイスの実際の位置認証状態には影響しません。
構文
このメソッドの構文を次に示します。
public static void setAuthorizationStatus(final PlacesAuthorizationStatus status);
例
このメソッドのコードサンプルを次に示します。
Places.setAuthorizationStatus(PlacesAuthorizationStatus.ALWAYS);
ACPPlaces v1.3.0 以降で使用可能
Places 拡張機能で認証ステータスを設定します。
提供されたステータスは「Places」共有状態に保存され、参照用にのみ表示されます。
このメソッドを呼び出しても、このデバイスの実際の位置認証状態には影響しません。
デバイスの認証ステータスが変更されると、 locationManager:didChangeAuthorizationStatus:
メソッド CLLocationManagerDelegate
が呼び出されます。 このメソッド内から、新しい CLAuthorizationStatus
値を ACPPlaces に設定 setAuthorizationStatus:
API
構文
このメソッドの構文を次に示します。
+ (void) setAuthorizationStatus: (CLAuthorizationStatus) status;
例
このメソッドのコードサンプルを次に示します。
- (void) locationManager: (CLLocationManager*) manager didChangeAuthorizationStatus: (CLAuthorizationStatus) status {
[ACPPlaces setAuthorizationStatus:status];
}