In-App Review API は、 Appleが 2016 年に iOS アプリ向けに行ったように、 Googleが 2020 年 8 月に開始した待望の機能です。
この API を使用すると、ユーザーはアプリケーションを離れずにレビューして評価できます。このAPIは、一度にアプリケーションの特定の使用について各ユーザーに割り当てを割り当てるため、ユーザーに常に評価またはレビューを強制しないように開発者に提案します。確かに開発者は、タスクの途中で魅力的なポップアップでユーザーの邪魔をすることはできません。
ジャワ
In Application level (build.gradle)
dependencies {
// This dependency from the Google Maven repository.
// include that repository in your project's build.gradle file.
implementation 'com.google.android.play:core:1.9.0'
}
boolean isGMSAvailable = false;
int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);
isGMSAvailable = (com.google.android.gms.common.ConnectionResult.SUCCESS == result);
if(isGMSAvailable)
{
ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
try {
if (task.isSuccessful())
{
// getting ReviewInfo object
ReviewInfo reviewInfo = task.getResult();
Task<Void> flow = manager.launchReviewFlow(this, reviewInfo);
flow.addOnCompleteListener(task2 -> {
// 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.
});
} else
{
// There was some problem, continue regardless of the result
// call old method for rating and user will land in Play Store App page
Utils.rateOnPlayStore(this);
}
} catch (Exception ex)
{
Log.e("review Ex", "review & rate: "+ ex);
}
});
}
else
{
// if user has not installed Google play services in his/her device you land them to
// specific store e.g. Huawei AppGallery or Samsung Galaxy Store
Utils.rateOnOtherStore(this);
}
コトリン
val manager = ReviewManagerFactory.create(context)
val request = manager.requestReviewFlow()
request.addOnCompleteListener { request ->
if (request.isSuccessful) {
// We got the ReviewInfo object
val reviewInfo = request.result
} else {
// There was some problem, continue regardless of the result.
}
}
//Launch the in-app review flow
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.
}
テスト用FakeReviewManager
//java
ReviewManager manager = new FakeReviewManager(this);
//Kotlin
val manager = FakeReviewManager(context)