How to call Play API's in-app review once in 10 days Android?

441 views Asked by At

I implemented Play Core Library's in-app review but the review pops up when I open the app for the first time.

Is there a way to open that pop-up box only after the app has been used for 10 days or something?

I have used this code to implement it:

    ReviewManager manager;
    ReviewInfo reviewInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.abc);
  

        manager = ReviewManagerFactory.create(this);
        Task<ReviewInfo> request = manager.requestReviewFlow();
        request.addOnCompleteListener(task -> {
            if (task.isSuccessful()) {
                // We can get the ReviewInfo object
                reviewInfo = task.getResult();
                openReview();
            }
        });
    }

    public void openReview(){
        if(reviewInfo != null){
            Task<Void> flow = manager.launchReviewFlow(this, 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.
            });
        } 
1

There are 1 answers

0
user14678216 On

I would do it like this:

  • When the app is first opened, record the date/time and save it in SharedPreferences
  • Every time the user opens the app do the current date/time - the date/time when the app was first opened.
  • If this value is more than 10 days, show the IAP Review dialog. Then you would reset the current date/time stored in SharedPreferences