简体   繁体   中英

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

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.
            });
        } 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM