Reputation: 273
In the documentation it's stated that the ReviewInfo object is only valid for a limited amount of time:
Note: The ReviewInfo object is only valid for a limited amount of time. Your app should request a ReviewInfo object ahead of time (pre-cache) but only once you are certain that your app will launch the in-app review flow.
How long (roughly) is the ReviewInfo object valid?
For example, can a game fetch the ReviewInfo at startup (if the user has played long enough), and then launch the review flow only if the user beats their high score, which could be 5, 10, 30 minutes down the line?
Upvotes: 8
Views: 1565
Reputation: 2194
As stated in the docs:
https://developer.android.com/guide/playcore/in-app-review/kotlin-java#request-review-info
Note: The ReviewInfo object is only valid for a limited amount of time. Your app should request a ReviewInfo object ahead of time (pre-cache) but only once you are certain that your app will launch the in-app review flow.
While you could potentially discover the TTL, it's an implementation detail, thus relaying on it could backfire.
I would not recommend to load on Application create, instead use some logic to guard the request.
For example, it's a common practice to try to display the request after screen transition once the user did an action successfully or whatever logic you want to apply. Meaning that on the previous screen you could start the request already and only once the new screen appears launch the flow.
See the PlayCoreKtx sample for an example https://github.com/android/app-bundle-samples/blob/master/PlayCoreKtx/app/src/main/java/com/google/android/samples/dynamicfeatures/state/ReviewViewModel.kt
Upvotes: 1
Reputation: 843
So, I did some testing on this issue and found out that the ReviewInfo remained valid for more than 2 hours, but less than 3.
I tested it by loading the ReviewInfo object during the app startup process and while the app was open I increased the device's time by 3 hours. In this case, it didn't work, but it did work when I used 2.
I also tested it with more hours (even days) and it never worked, but coming back to 2 hours made the dialog appear normally, so I think that's their current threshold. Note though that according to the documentation they can change this anytime, so trade carefully.
Upvotes: 5