인앱 설치 프롬프트 통합

이 가이드에서는 Kotlin 또는 자바를 사용하여 앱에 인앱 설치 메시지를 통합하는 방법을 설명합니다.

개발 환경 설정

Play In-App Install Prompts 라이브러리는 Google Play Core 라이브러리의 일부입니다. 라이브러리를 사용하려면 다음 Gradle 종속 항목을 포함하세요.

// In your app's build.gradle.kts file:
...
dependencies {
    implementation("com.google.android.play:crossdeviceprompt:0.0.1")
    ...
}

교차 기기 설치 메시지 표시

앱의 흐름에서 사용자가 다른 기기에 앱을 설치하도록 메시지를 표시하는 가장 좋은 시점을 결정합니다 (예: 사용자가 휴대전화에서 TV로 동영상을 전송할 때). 앱은 이러한 지점 중 하나에 도달하면 다음 단계를 실행합니다.

  1. CrossDevicePromptInstallationRequest를 만듭니다.
  2. CrossDevicePromptManager를 사용하여 요청을 매개변수로 허용하는 요청 태스크를 만듭니다.
  3. 결과 CrossDevicePromptInfo 객체를 launchPromptFlow()와 함께 사용하여 사용자에게 메시지를 표시합니다.

CrossDevicePromptInfo를 가져오거나 메시지를 표시하는 중에 오류가 발생하면 예외가 발생합니다.

val crossDevicePromptManager = CrossDevicePromptManagerFactory.create(activity)
val request = CrossDevicePromptInstallationRequest.create()

try {
    val info = crossDevicePromptManager.requestInstallationPromptFlow(request).await()
    crossDevicePromptManager.launchPromptFlow(activity, info).await()
} catch (e: CrossDevicePromptException) {
    Log.e(TAG, "Cross-device prompt failed with error: ${e.errorCode}", e)
}

구현을 확인하려면 인앱 설치 메시지 테스트를 참고하세요.