Android SDK - コンフィギュレーション・メソッド・リファレンス
Singular SDKはSingularConfigクラスを通して柔軟なコンフィギュレーションシステムを提供します。このドキュメントでは、SDKを初期化する際に利用可能なすべての設定オプションとその使用方法について概説します。
withCustomSdid
SingularConfig.withCustomSdid メソッド
エンタープライズ機能:カスタムSingularデバイスID(SDID)とそれにアクセスするハンドラを設定します。
シグネチャ
public SingularConfig withCustomSdid(String customSdid, SDIDAccessorHandler accessorHandler)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withCustomSdid("custom-device-id-12345", new SDIDAccessorHandler() {
@Override
public void onSDIDAccessed(String sdid) {
// Handle SDID access
Log.d("Singular", "SDID accessed: " + sdid);
}
});
withCustomUserId
SingularConfig.withCustomUserId メソッド
初期化中にカスタムユーザー ID を設定します。
シグネチャ
public SingularConfig withCustomUserId(String customUserId)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withCustomUserId("user_12345");
withDDLHandler
SingularConfig.withDDLHandler メソッド
遅延ディープリンクのハンドラを設定します。
シグネチャ
public SingularConfig withDDLHandler(DeferredDeepLinkHandler handler)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withDDLHandler(new DeferredDeepLinkHandler() {
@Override
public void onResolved(String resolvedLink) {
if (resolvedLink != null) {
// Handle the deferred deep link
Log.d("Singular", "Deferred deep link: " + resolvedLink);
}
}
});
withDDLTimeoutInSec
SingularConfig.withDDLTimeoutInSec メソッド
遅延ディープリンク解決のタイムアウトを秒で設定します。
シグネチャ
public SingularConfig withDDLTimeoutInSec(long timeout)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withDDLHandler(deferredDeepLinkHandler)
.withDDLTimeoutInSec(10); // 10 seconds timeout
withESPDomains
SingularConfig.withESPDomains メソッド
Eメールキャンペーンからのアトリビューションを処理するためのESP(Eメールサービスプロバイダ)ドメインのリストを設定します。
シグネチャ
public SingularConfig withESPDomains(List espDomains)
使用例
List<String> espDomains = new ArrayList<>();
espDomains.add("email.example.com");
espDomains.add("newsletter.example.com");
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withESPDomains(espDomains);
withFacebookAppId
SingularConfig.withFacebookAppId メソッド
Facebookアトリビューション用のFacebookアプリIDを設定します。
シグネチャ
public SingularConfig withFacebookAppId(String facebookAppId)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withFacebookAppId("123456789012345");
withFCMDeviceToken
SingularConfig.withFCMDeviceToken メソッド
初期化時に Firebase Cloud Messaging デバイス トークンを設定します。
シグネチャ
public SingularConfig withFCMDeviceToken(String fcmDeviceToken)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withFCMDeviceToken("eKh2BNP-Txy4XrjDGmw...");
withGlobalProperty
SingularConfig.withGlobalProperty メソッド
初期化時にグローバルプロパティを設定します。
シグネチャ
public SingularConfig withGlobalProperty(String key, String value, boolean overrideExisting)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withGlobalProperty("app_version", "2.1.0", true)
.withGlobalProperty("user_type", "free", true);
withIMEI
SingularConfig.withIMEI メソッド
初期化中に追跡用のデバイス IMEI を設定します。
シグネチャ
public SingularConfig withIMEI(String imei)
使用例
// Note: Requires READ_PHONE_STATE permission
String imei = null;
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
== PackageManager.PERMISSION_GRANTED) {
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
imei = telephonyManager.getDeviceId();
}
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withIMEI(imei);
withLimitAdvertisingIdentifiers
SingularConfig.withLimitAdvertisingIdentifiers メソッド
初期化中に広告識別子の使用を制限します。
シグネチャ
public SingularConfig withLimitAdvertisingIdentifiers()
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withLimitAdvertisingIdentifiers();
withLimitDataSharing
SingularConfig.withLimitDataSharing メソッド
初期化時にパートナーやネットワークとのデータ共有を制限するかどうかを制御します。
シグネチャ
public SingularConfig withLimitDataSharing(boolean shouldLimitDataSharing)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withLimitDataSharing(true);
withLogLevel
SingularConfig.withLogLevel メソッド
SDKログのログレベルを設定します。
シグネチャ
public SingularConfig withLogLevel(int level)
使用例
import android.util.Log;
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withLoggingEnabled()
.withLogLevel(Log.VERBOSE); // Use Log.VERBOSE, Log.DEBUG, Log.INFO, Log.WARN, Log.ERROR
withLoggingEnabled
SingularConfig.withLoggingEnabled メソッド
SDKのロギングを有効にします。
シグネチャ
public SingularConfig withLoggingEnabled()
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withLoggingEnabled();
withOAIDCollection
SingularConfig.withOAIDCollection メソッド
中国デバイスのOAID(Open Anonymous Device Identifier)の収集を有効にします。
シグネチャ
public SingularConfig withOAIDCollection()
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withOAIDCollection();
withOpenURI
SingularConfig.withOpenURI メソッド
アトリビューションのためにアプリを開いたURIを設定します。
シグネチャ
public SingularConfig withOpenURI(Uri openUri)
使用例
// In your Activity's onCreate method
Uri data = getIntent().getData();
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withOpenURI(data);
withPushNotificationPayload
SingularConfig.withPushNotificationPayload メソッド
プッシュ通知のペイロードと、ペイロードからディープリンクを抽出するパスを設定します。
シグネチャ
public SingularConfig withPushNotificationPayload(Intent intent, String[] ... pushNotificationLinkPath)
使用例
// In your Activity that handles push notifications
Intent intent = getIntent();
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withPushNotificationPayload(intent, new String[]{"singular_link"}, new String[]{"data", "deeplink"});
withSdidAccessorHandler
SingularConfig.withSdidAccessorHandler メソッド
エンタープライズ機能:Singular Device ID (SDID) にアクセスするハンドラを設定します。
シグネチャ
public SingularConfig withSdidAccessorHandler(SDIDAccessorHandler accessorHandler)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withSdidAccessorHandler(new SDIDAccessorHandler() {
@Override
public void onSDIDAccessed(String sdid) {
// Handle SDID access
Log.d("Singular", "SDID accessed: " + sdid);
}
});
withSessionTimeoutInSec
SingularConfig.withSessionTimeoutInSec メソッド
セッションタイムアウトを秒単位で設定します。
シグネチャ
public SingularConfig withSessionTimeoutInSec(long timeout)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withSessionTimeoutInSec(60); // 60 seconds timeout
withSingularDeviceAttribution
SingularConfig.withSingularDeviceAttribution メソッド
BETA機能:デバイス属性データが利用可能になったときに受信するハンドラ関数を設定します。
シグネチャ
public SingularConfig withSingularDeviceAttribution(SingularDeviceAttributionHandler handler)
使用例
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withSingularDeviceAttribution(new SingularDeviceAttributionHandler() {
@Override
public void onDeviceAttributionInfoReceived(Map deviceAttributionData) {
// Handle device attribution data
if (deviceAttributionData != null) {
for (Object key : deviceAttributionData.keySet()) {
Log.d("Singular", key + ": " + deviceAttributionData.get(key));
}
}
}
});
withSingularLink
SingularConfig.withSingularLink メソッド
解決されたリンクのコールバックを持つSingular Links処理を設定します。
シグネチャ
public SingularConfig withSingularLink(Intent intent, SingularLinkHandler handler)
public SingularConfig withSingularLink(Intent intent, SingularLinkHandler handler, long shortlinkTimeoutSec)
使用例
// In your Activity's onCreate method
Intent intent = getIntent();
SingularConfig config = new SingularConfig("API_KEY", "API_SECRET")
.withSingularLink(intent, new SingularLinkHandler() {
@Override
public void onResolved(SingularLinkParams params) {
if (params != null) {
// Handle the deep link
String deeplink = params.getDeeplink();
if (deeplink != null) {
Log.d("Singular", "Deep link: " + deeplink);
// Navigate to the appropriate screen
}
// Get passthrough parameters
String passthrough = params.getPassthrough();
if (passthrough != null) {
Log.d("Singular", "Passthrough: " + passthrough);
}
// Check if this is a deferred deep link
boolean isDeferred = params.isDeferred();
Log.d("Singular", "Is deferred: " + isDeferred);
}
}
}, 10); // 10 seconds timeout
完全なコンフィギュレーションの例
複数の設定オプションの連結
Singular SDK を初期化するときに複数の設定オプションを連結する方法を示す完全な例です。
使用例
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.singular.sdk.Singular;
import com.singular.sdk.SingularConfig;
import com.singular.sdk.SingularLinkHandler;
import com.singular.sdk.SingularLinkParams;
import com.singular.sdk.SingularDeviceAttributionHandler;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get the intent that started this activity
Intent intent = getIntent();
// Initialize Singular SDK with advanced configuration
SingularConfig config = new SingularConfig("SDK KEY", "YOUR_SECRET")
// Enable logging for debugging
.withLoggingEnabled()
.withLogLevel(Log.DEBUG)
// Set custom user ID if available
.withCustomUserId("user_12345")
// Configure session timeout
.withSessionTimeoutInSec(60)
// Set global properties for all events
.withGlobalProperty("app_version", "2.1.0", true)
.withGlobalProperty("user_type", "premium", true)
// Handle deep links
.withSingularLink(intent, new SingularLinkHandler() {
@Override
public void onResolved(SingularLinkParams params) {
if (params != null) {
String deeplink = params.getDeeplink();
if (deeplink != null) {
Log.d("Singular", "Deep link: " + deeplink);
// Navigate based on deep link
}
}
}
}, 10)
// Handle deferred deep links
.withDDLHandler(new DeferredDeepLinkHandler() {
@Override
public void onResolved(String resolvedLink) {
if (resolvedLink != null) {
Log.d("Singular", "Deferred deep link: " + resolvedLink);
// Handle deferred deep link
}
}
})
.withDDLTimeoutInSec(5)
// Get device attribution data
.withSingularDeviceAttribution(new SingularDeviceAttributionHandler() {
@Override
public void onDeviceAttributionInfoReceived(Map deviceAttributionData) {
if (deviceAttributionData != null) {
for (Object key : deviceAttributionData.keySet()) {
Log.d("Singular", key + ": " + deviceAttributionData.get(key));
}
}
}
})
// Facebook attribution
.withFacebookAppId("123456789012345")
// Configure data sharing limitations for privacy
.withLimitDataSharing(true)
.withLimitAdvertisingIdentifiers();
// Initialize the SDK with the configuration
Singular.init(this, config);
}
@Override
protected void onResume() {
super.onResume();
Singular.onActivityResumed();
}
@Override
protected void onPause() {
super.onPause();
Singular.onActivityPaused();
}
}