Places拡張機能を使用すると、ユーザの場所に基づいて操作を行うことができます。 この拡張機能は、PlacesクエリサービスAPIへのインターフェイスです。 GPS座標とジオフェンス領域のイベントを含むイベントをリッスンすると、この拡張は、ルールエンジンで処理される新しいイベントをディスパッチします。 また、Places拡張は、APIから取得したアプリデータに最も近いPOIのリストを取得し、配信します。 APIから返される領域はキャッシュと永続性に保存されるので、オフライン処理に制限があります。
Experience Platform Launchで、「拡張子」タブをクリックします。
「カタログ」タブで、場所拡張子を探し、インストールをクリックします。
このプロパティで使用する場所ライブラリを選択します。 これらは、アプリケーションでアクセスできるライブラリです。
「保存」をクリックします。
「保存」をクリックすると、Experience PlatformSDKは、選択したライブラリ内のPOIをPlaces Servicesで検索します。 POIデータは、アプリケーションの構築時にライブラリのダウンロードには含まれませんが、POIの場所ベースのサブセットは、実行時にエンドユーザーのデバイスにダウンロードされ、ユーザーのGPS座標に基づきます。
公開プロセスを完了して、SDK設定を更新します。
Experience Platform Launchでの公開について詳しくは、公開を参照してください。
Places拡張機能は、AndroidおよびiOSアプリに追加できます。 iOSまたはAndroidアプリケーションに場所を追加する手順は、次のとおりです。 プレース拡張は、次のプラットフォームでも利用できます。 以下のプラットフォームのいずれかを使用して開発する場合、アプリケーションに場所を追加する方法については、付属のリンクを参照してください。
Javaを使用してPlaces拡張をアプリに追加するには:
アプリ追加のグレードルファイルを使用して、プロジェクトに拡張子を配置します。
implementation 'com.adobe.marketing.mobile:places:1.+'
implementation 'com.adobe.marketing.mobile:sdk-core:1.+'
Places拡張機能をアプリケーションのメインアクティビティに読み込みます。
import com.adobe.marketing.mobile.Places;
Objective-CまたはSwiftを使用してPlaces拡張をアプリに追加するには:
プロジェクト追加に配置し、モバイルコアライブラリを配置します。 Podfile
に次のポッドを追加する必要があります。
pod 'ACPPlaces', '~> 1.0'
pod 'ACPCore', '~> 2.0' # minimum Core version for Places is 2.0.3
または、Cocoapodsを使用していない場合は、GithubのリリースページからMobile CoreとPlacesライブラリを手動で含めることもできます。
Cocoapodsの更新:
pod update
Xcodeを開き、AppDelegateクラスで、CoreヘッダーとPlacesヘッダーを読み込みます。
Objective-C
#import "ACPCore.h"
#import "ACPPlaces.h"
Swift
import ACPCore
import ACPPlaces
Places拡張機能をAndroidおよびiOSのMobile Coreに登録する必要があります。
アプリのOnCreate
メソッドで、Places拡張を登録します。
public class PlacesTestApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
try {
Places.registerExtension();
MobileCore.start(null);
} catch (Exception e) {
Log.e("PlacesTestApp", e.getMessage());
}
}
}
アプリのapplication:didFinishLaunchingWithOptions:
メソッドで、Places拡張を他のSDK登録呼び出しに登録します。
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// make other sdk registration calls
[ACPPlaces registerExtension];
return YES;
}
スウィフト
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// make other sdk registration calls
ACPPlaces.registerExtension();
return true;
}
特にデバイスがバックグラウンドで場所の更新を受け取っていない場合、場所データはすぐに古くなる可能性があります。
places.membershipttl
構成設定を設定して、デバイス上のPlacesメンバーシップデータの有効期間を制御します。 渡される値は、Places状態がデバイスに対して有効なままである秒数を表します。
MobileCore.start()
のコールバック内で、lifecycleStart
を呼び出す前に、必要な変更を加えて設定を更新します。
public class PlacesTestApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
try {
Places.registerExtension();
MobileCore.start(new AdobeCallback() {
@Override
public void call(Object o) {
// switch to your App ID from Launch
MobileCore.configureWithAppID("my-app-id");
final Map<String, Object> config = new HashMap<>();
config.put("places.membershipttl", 30);
MobileCore.updateConfiguration(config);
MobileCore.lifecycleStart(null);
}
});
} catch (Exception e) {
Log.e("PlacesTestApp", e.getMessage());
}
}
}
ACPCore
のstart:
メソッドのコールバックの最初の行で、updateConfiguration:
を呼び出します。
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// make other sdk registration calls
const UIApplicationState appState = application.applicationState;
[ACPCore start:^{
[ACPCore updateConfiguration:@{@"places.membershipttl":@(30)}];
if (appState != UIApplicationStateBackground) {
[ACPCore lifecycleStart:nil];
}
}];
return YES;
}
スウィフト
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// make other sdk registration calls
let appState = application.applicationState;
ACPCore.start {
ACPCore.updateConfiguration(["places.membershipttl" : 30])
if appState != .background {
ACPCore.lifecycleStart(nil)
}
}
return true;
}
実行時にSDK設定をプログラムで更新するには、次の情報を使用してPlaces拡張の設定値を変更します。 詳しくは、設定APIリファレンスを参照してください。
キー | 必須 | 説明 |
---|---|---|
places.libraries |
○ | モバイルアプリ用のPlaces拡張ライブラリ。 ライブラリIDと、モバイルアプリケーションがサポートするライブラリの名前を指定します。 |
places.endpoint |
○ | デフォルトの配置クエリサービスエンドポイントです。このエンドポイントは、ライブラリとPOIに関する情報の取得に使用されます。 |
places.membershipttl |
× | デフォルト値は3600(1時間あたりの秒数)です。 デバイスのメンバーシップ情報を保持する時間(秒)を示します。 |