Интегрируйте обзоры в приложении (Kotlin или Java)

В этом руководстве описывается, как интегрировать внутренние обзоры в ваше приложение с помощью Kotlin или Java. Если вы используете собственный код или Unity , существуют отдельные руководства по интеграции.

Настройте среду разработки

Библиотека обзоров внутри приложений Play является частью библиотек Google Play Core . Пожалуйста, включите следующую зависимость Gradle для интеграции библиотеки отзывов Play в приложении.

классный

// In your app’s build.gradle file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation 'com.google.android.play:review:2.0.1'

    // For Kotlin users also add the Kotlin extensions library for Play In-App Review:
    implementation 'com.google.android.play:review-ktx:2.0.1'
    ...
}

Котлин

// In your app’s build.gradle.kts file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation("com.google.android.play:review:2.0.1")

    // For Kotlin users also import the Kotlin extensions library for Play In-App Review:
    implementation("com.google.android.play:review-ktx:2.0.1")
    ...
}

Создайте менеджер отзывов

ReviewManager — это интерфейс, который позволяет вашему приложению запустить процесс проверки внутри приложения. Получите его, создав экземпляр с помощью ReviewManagerFactory .

Котлин

val manager = ReviewManagerFactory.create(context)

Ява

ReviewManager manager = ReviewManagerFactory.create(context)

Запросить объект ReviewInfo

Следуйте инструкциям о том , когда запрашивать проверку в приложении, чтобы определить хорошие моменты в потоке пользователя вашего приложения и предложить пользователю оставить отзыв (например, когда пользователь завершает уровень в игре). Когда ваше приложение достигнет одной из этих точек, используйте экземпляр ReviewManager для создания задачи запроса. В случае успеха API возвращает объект ReviewInfo , необходимый для запуска процесса проверки в приложении.

Котлин

val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
    if (task.isSuccessful) {
        // We got the ReviewInfo object
        val reviewInfo = task.result
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode val reviewErrorCode = (task.getException() as ReviewException).errorCode
    }
}

Ява

ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
    if (task.isSuccessful()) {
        // We can get the ReviewInfo object
        ReviewInfo reviewInfo = task.getResult();
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode int reviewErrorCode = ((ReviewException) task.getException()).getErrorCode();
    }
});

Запустите процесс проверки в приложении

Используйте экземпляр ReviewInfo , чтобы запустить процесс проверки в приложении. Подождите, пока пользователь завершит процесс проверки в приложении, прежде чем ваше приложение продолжит свою обычную работу (например, перейдет на следующий уровень).

Котлин

val flow = manager.launchReviewFlow(activity, reviewInfo)
flow.addOnCompleteListener { _ ->
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
}

Ява

Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task -> {
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
});

Следующие шаги

Проверьте процесс проверки вашего приложения внутри приложения , чтобы убедиться, что ваша интеграция работает правильно.

,

В этом руководстве описывается, как интегрировать внутренние обзоры в ваше приложение с помощью Kotlin или Java. Если вы используете собственный код или Unity , существуют отдельные руководства по интеграции.

Настройте среду разработки

Библиотека обзоров внутри приложений Play является частью библиотек Google Play Core . Пожалуйста, включите следующую зависимость Gradle для интеграции библиотеки отзывов Play в приложении.

классный

// In your app’s build.gradle file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation 'com.google.android.play:review:2.0.1'

    // For Kotlin users also add the Kotlin extensions library for Play In-App Review:
    implementation 'com.google.android.play:review-ktx:2.0.1'
    ...
}

Котлин

// In your app’s build.gradle.kts file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation("com.google.android.play:review:2.0.1")

    // For Kotlin users also import the Kotlin extensions library for Play In-App Review:
    implementation("com.google.android.play:review-ktx:2.0.1")
    ...
}

Создайте менеджер отзывов

ReviewManager — это интерфейс, который позволяет вашему приложению запустить процесс проверки внутри приложения. Получите его, создав экземпляр с помощью ReviewManagerFactory .

Котлин

val manager = ReviewManagerFactory.create(context)

Ява

ReviewManager manager = ReviewManagerFactory.create(context)

Запросить объект ReviewInfo

Следуйте инструкциям о том , когда запрашивать проверку в приложении, чтобы определить хорошие моменты в потоке пользователей вашего приложения и предложить пользователю оставить отзыв (например, когда пользователь завершает уровень в игре). Когда ваше приложение достигнет одной из этих точек, используйте экземпляр ReviewManager для создания задачи запроса. В случае успеха API возвращает объект ReviewInfo , необходимый для запуска процесса проверки в приложении.

Котлин

val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
    if (task.isSuccessful) {
        // We got the ReviewInfo object
        val reviewInfo = task.result
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode val reviewErrorCode = (task.getException() as ReviewException).errorCode
    }
}

Ява

ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
    if (task.isSuccessful()) {
        // We can get the ReviewInfo object
        ReviewInfo reviewInfo = task.getResult();
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode int reviewErrorCode = ((ReviewException) task.getException()).getErrorCode();
    }
});

Запустите процесс проверки в приложении

Используйте экземпляр ReviewInfo , чтобы запустить процесс проверки в приложении. Подождите, пока пользователь завершит процесс проверки в приложении, прежде чем ваше приложение продолжит свою обычную работу (например, перейдет на следующий уровень).

Котлин

val flow = manager.launchReviewFlow(activity, reviewInfo)
flow.addOnCompleteListener { _ ->
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
}

Ява

Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task -> {
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
});

Следующие шаги

Проверьте процесс проверки вашего приложения внутри приложения , чтобы убедиться, что ваша интеграция работает правильно.

,

В этом руководстве описывается, как интегрировать внутренние обзоры в ваше приложение с помощью Kotlin или Java. Если вы используете собственный код или Unity , существуют отдельные руководства по интеграции.

Настройте среду разработки

Библиотека обзоров внутри приложений Play является частью библиотек Google Play Core . Пожалуйста, включите следующую зависимость Gradle для интеграции библиотеки отзывов Play в приложении.

классный

// In your app’s build.gradle file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation 'com.google.android.play:review:2.0.1'

    // For Kotlin users also add the Kotlin extensions library for Play In-App Review:
    implementation 'com.google.android.play:review-ktx:2.0.1'
    ...
}

Котлин

// In your app’s build.gradle.kts file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation("com.google.android.play:review:2.0.1")

    // For Kotlin users also import the Kotlin extensions library for Play In-App Review:
    implementation("com.google.android.play:review-ktx:2.0.1")
    ...
}

Создайте менеджер отзывов

ReviewManager — это интерфейс, который позволяет вашему приложению запустить процесс проверки внутри приложения. Получите его, создав экземпляр с помощью ReviewManagerFactory .

Котлин

val manager = ReviewManagerFactory.create(context)

Ява

ReviewManager manager = ReviewManagerFactory.create(context)

Запросить объект ReviewInfo

Следуйте инструкциям о том , когда запрашивать проверку в приложении, чтобы определить хорошие моменты в потоке пользователей вашего приложения и предложить пользователю оставить отзыв (например, когда пользователь завершает уровень в игре). Когда ваше приложение достигнет одной из этих точек, используйте экземпляр ReviewManager для создания задачи запроса. В случае успеха API возвращает объект ReviewInfo , необходимый для запуска процесса проверки в приложении.

Котлин

val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
    if (task.isSuccessful) {
        // We got the ReviewInfo object
        val reviewInfo = task.result
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode val reviewErrorCode = (task.getException() as ReviewException).errorCode
    }
}

Ява

ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
    if (task.isSuccessful()) {
        // We can get the ReviewInfo object
        ReviewInfo reviewInfo = task.getResult();
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode int reviewErrorCode = ((ReviewException) task.getException()).getErrorCode();
    }
});

Запустите процесс проверки в приложении

Используйте экземпляр ReviewInfo , чтобы запустить процесс проверки в приложении. Подождите, пока пользователь завершит процесс проверки в приложении, прежде чем ваше приложение продолжит свою обычную работу (например, перейдет на следующий уровень).

Котлин

val flow = manager.launchReviewFlow(activity, reviewInfo)
flow.addOnCompleteListener { _ ->
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
}

Ява

Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task -> {
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
});

Следующие шаги

Проверьте процесс проверки вашего приложения внутри приложения , чтобы убедиться, что ваша интеграция работает правильно.

,

В этом руководстве описывается, как интегрировать внутренние обзоры в ваше приложение с помощью Kotlin или Java. Если вы используете собственный код или Unity , существуют отдельные руководства по интеграции.

Настройте среду разработки

Библиотека обзоров внутри приложений Play является частью библиотек Google Play Core . Пожалуйста, включите следующую зависимость Gradle для интеграции библиотеки отзывов Play в приложении.

классный

// In your app’s build.gradle file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation 'com.google.android.play:review:2.0.1'

    // For Kotlin users also add the Kotlin extensions library for Play In-App Review:
    implementation 'com.google.android.play:review-ktx:2.0.1'
    ...
}

Котлин

// In your app’s build.gradle.kts file:
...
dependencies {
    // This dependency is downloaded from the Google’s Maven repository.
    // So, make sure you also include that repository in your project's build.gradle file.
    implementation("com.google.android.play:review:2.0.1")

    // For Kotlin users also import the Kotlin extensions library for Play In-App Review:
    implementation("com.google.android.play:review-ktx:2.0.1")
    ...
}

Создайте менеджер отзывов

ReviewManager — это интерфейс, который позволяет вашему приложению запустить процесс проверки внутри приложения. Получите его, создав экземпляр с помощью ReviewManagerFactory .

Котлин

val manager = ReviewManagerFactory.create(context)

Ява

ReviewManager manager = ReviewManagerFactory.create(context)

Запросить объект ReviewInfo

Следуйте инструкциям о том , когда запрашивать проверку в приложении, чтобы определить хорошие моменты в потоке пользователя вашего приложения и предложить пользователю оставить отзыв (например, когда пользователь завершает уровень в игре). Когда ваше приложение достигнет одной из этих точек, используйте экземпляр ReviewManager для создания задачи запроса. В случае успеха API возвращает объект ReviewInfo , необходимый для запуска процесса проверки в приложении.

Котлин

val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
    if (task.isSuccessful) {
        // We got the ReviewInfo object
        val reviewInfo = task.result
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode val reviewErrorCode = (task.getException() as ReviewException).errorCode
    }
}

Ява

ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
    if (task.isSuccessful()) {
        // We can get the ReviewInfo object
        ReviewInfo reviewInfo = task.getResult();
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode int reviewErrorCode = ((ReviewException) task.getException()).getErrorCode();
    }
});

Запустите процесс проверки в приложении

Используйте экземпляр ReviewInfo , чтобы запустить процесс проверки в приложении. Подождите, пока пользователь завершит процесс проверки в приложении, прежде чем ваше приложение продолжит свою обычную работу (например, перейдет на следующий уровень).

Котлин

val flow = manager.launchReviewFlow(activity, reviewInfo)
flow.addOnCompleteListener { _ ->
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
}

Ява

Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task -> {
    // The flow has finished. The API does not indicate whether the user
    // reviewed or not, or even whether the review dialog was shown. Thus, no
    // matter the result, we continue our app flow.
});

Следующие шаги

Проверьте процесс проверки вашего приложения внутри приложения , чтобы убедиться, что ваша интеграция работает правильно.