メインコンテンツまでスキップ

Android SDK ベストプラクティス

モバイルアプリケーションのパフォーマンスは、ビジネスにとって非常に重要です。Adjustのテクノロジーは、アプリの顧客体験を改善することに焦点を当てています。したがって、画面のパフォーマンスはAdjustのソリューションの中核を成すコンポーネントです。エンゲージメントおよびコンバージョン率を向上させるために、Adjustは画面のロード時間を最小限に抑えるためのさまざまなアプローチを採用しています。

Jetpack Compose コンポーネント

Rokt Android SDKのメジャーバージョン4から、RoktLayoutのコンポーザブルを使用してRoktレイアウトを追加できるようになりました。これにより、Rokt.executeを呼び出す必要がなくなり、プレースメントを追加するで説明されているように、Composeを使ったよりモダンな宣言型統合がサポートされます。

コンポーネントを追加する

import com.rokt.roktsdk.RoktLayout

@Composable
fun MainScreen(modifier: Modifier = Modifier) {
Column(
modifier = modifier
.background(Color.LightGray)
.padding(8.dp),
) {
// アプリケーションがライトモードのみをサポートしている場合
val config = remember {
RoktConfig.Builder().colorMode(RoktConfig.ColorMode.LIGHT).build()
}
RoktLayout(
sdkTriggered = true,
viewName = "RoktExperience",
attributes = mapOf(
"email" to "j.smith@example.com",
"firstname" to "Jenny",
"lastname" to "Smith",
"mobile" to "(323) 867-5309",
"postcode" to "90210",
"country" to "US"
),
location = "RoktEmbedded1", // 埋め込みレイアウトを使用している場合
onLoad = {},
onUnload = {},
config = config,
onShouldShowLoadingIndicator = {},
onShouldHideLoadingIndicator = {},
)
}
}
注記

RoktLayoutのコンポーザブルは、組み込みレイアウトとオーバーレイレイアウトの両方で使用できます。

アプリケーション設定の使用

アプリケーションは、自身のアプリケーション環境から設定を渡すことができるようになりました。これにより、Rokt SDKがシステムのデフォルトに頼るのではなく、アプリケーションのカスタム設定を使用することができます。

ColorMode オブジェクト

説明
LIGHTアプリケーションはライトモードです
DARKアプリケーションはダークモードです
SYSTEMアプリケーションはシステムのカラーモードをデフォルトとします
import com.rokt.roktsdk.Rokt

// アプリケーションがライトモードのみをサポートする場合。
val roktConfig = RoktConfig.Builder().colorMode(RoktConfig.ColorMode.LIGHT).build()
Rokt.execute(
// その他のパラメータ,
config = roktConfig,
)

CacheConfig オブジェクト

パラメータ説明
cacheDurationオプションの期間で、Rokt SDKがエクスペリエンスをキャッシュする秒数。最大許可値は90分で、デフォルト(提供されないか無効な値の場合)も90分です。
cacheAttributesキャッシュキーとして使用するオプションの属性です。nullの場合、Rokt.executeに送信されたすべての属性がキャッシュキーとして使用されます。
import com.rokt.roktsdk.Rokt

// 1200秒間エクスペリエンスをキャッシュし、emailとorderNumber属性をキャッシュキーとして使用します。
val roktConfig = RoktConfig.Builder().cacheConfig(
CacheConfig(
cacheDurationInSeconds = 1200,
cacheAttributes = mapOf("email" to "j.smith@example.com", "orderNumber" to "123")
)
).build()

Rokt.execute(
// その他のパラメータ,
config = roktConfig,
)

フォント書体の使用

Android SDKの初期化 に記載されているように独自のフォント書体を使用している場合、executeに書体オブジェクトの弱参照のマップを渡す必要があります。

import com.rokt.roktsdk.Rokt;

class ConfirmationActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...

Map<String,String> attributes = new HashMap<String, String>();

attributes.put("email", "j.smith@example.com");
attributes.put("firstname", "Jenny");
attributes.put("lastname", "Smith");
attributes.put("mobile", "(323) 867-5309");
attributes.put("postcode", "90210");
attributes.put("country", "US");

Map<String, WeakReference<Typeface>> fontTypefaces = new HashMap<>();

fontTypefaces.put("Arial-Bold", new WeakReference<>(yourTypefaceObject));

Rokt.INSTANCE.execute("RoktExperience",
attributes,
new Rokt.RoktCallback() {
@Override
public void onLoad() {
}
@Override
public void onUnload(Rokt.UnloadReasons unloadReasons) {
}
@Override
public void onShouldHideLoadingIndicator() {
}
@Override
public void onShouldShowLoadingIndicator() {
}
},
fontTypefaces
)
...
}
}

詳細については、how-to sectionを参照してください。

この記事は役に立ちましたか?