Class AppReview
Entry point for requesting an app store review and collecting feedback.
AppReview prefers the platform's native review prompt
(SKStoreReviewController on iOS, the Play In-App Review API on Android)
and transparently falls back to a Codename One drawn rating widget on the
simulator, desktop, the web target and platforms/OS versions without a
native prompt.
There are two ways to use it:
-
Manual -- call
requestReview()at a moment that makes sense in your app (e.g. right after the user completed a meaningful task). You decide the timing entirely. -
Scheduled -- configure the engagement heuristics once and call
registerSession()on every app start.AppReviewkeeps a small amount of state inPreferences(launch count, install date, last prompt time) and only prompts once the thresholds are met and the user has not already rated or opted out.
The fallback widget routes high ratings to the store and low ratings to a
private feedback channel so unhappy users are heard before they post a one
star public review (see setHighRatingThreshold(int) and
setFeedbackListener(FeedbackListener)).
AppReview.getInstance()
.setStoreUrl("https://apps.apple.com/app/id0000000000")
.setSupportEmail("support@example.com")
.registerSession();
-
Method Summary
Modifier and TypeMethodDescriptionstatic AppReviewThe sharedAppReviewinstance.voidPermanently stops the scheduler from prompting again (the user rated the app or chose "don't ask again").voidRecords the current app session and, when the configured engagement thresholds are satisfied and the user has not already rated or opted out, prompts for a review.voidImmediately asks the user for a review.voidreset()Clears all persisted engagement state (launch count, install date, last prompt time and the completed flag) so the engagement cycle starts over.setDaysBetweenPrompts(int daysBetweenPrompts) The minimum number of days between two consecutive review prompts shown by the scheduler.setFeedbackListener(FeedbackListener feedbackListener) Registers a listener that intercepts the outcome of the fallback rating widget so feedback can be delivered through your own channel.setHighRatingThreshold(int highRatingThreshold) The lowest star value (1-5) that is still considered a positive rating in the fallback widget.setMinimumDaysInstalled(int minimumDaysInstalled) The number of days that must elapse after the first recorded launch before the scheduler will prompt for a review.setMinimumLaunches(int minimumLaunches) The number of app launches that must accumulate before the scheduler inregisterSession()will prompt for a review.setStoreUrl(String storeUrl) The store URL opened by the fallback widget for a positive rating (and used when no native prompt is available).setSupportEmail(String supportEmail) The support e-mail address used by the fallback widget to collect feedback for low ratings when noFeedbackListenerhandled it.booleanWhetherregisterSession()would prompt for a review given the current persisted state and configuration.
-
Method Details
-
getInstance
The shared
AppReviewinstance.Returns
the singleton used by the whole application.
-
setMinimumLaunches
The number of app launches that must accumulate before the scheduler in
registerSession()will prompt for a review. Defaults to 5.Returns
this instance for chaining.
-
setMinimumDaysInstalled
The number of days that must elapse after the first recorded launch before the scheduler will prompt for a review. Defaults to 3.
Returns
this instance for chaining.
-
setDaysBetweenPrompts
The minimum number of days between two consecutive review prompts shown by the scheduler. Defaults to 30.
Returns
this instance for chaining.
-
setHighRatingThreshold
The lowest star value (1-5) that is still considered a positive rating in the fallback widget. Ratings at or above this value send the user to the store, lower ratings open the private feedback flow. Defaults to 4.
Returns
this instance for chaining.
-
setStoreUrl
The store URL opened by the fallback widget for a positive rating (and used when no native prompt is available). On iOS/Android with a native prompt this is not needed. Typically your App Store or Google Play listing URL.
Returns
this instance for chaining.
-
setSupportEmail
The support e-mail address used by the fallback widget to collect feedback for low ratings when no
FeedbackListenerhandled it. When null and no listener is set, the feedback step is skipped.Returns
this instance for chaining.
-
setFeedbackListener
Registers a listener that intercepts the outcome of the fallback rating widget so feedback can be delivered through your own channel.
Returns
this instance for chaining.
-
registerSession
public void registerSession()Records the current app session and, when the configured engagement thresholds are satisfied and the user has not already rated or opted out, prompts for a review. Call this once per app start (e.g. from thestartlifecycle method). It is cheap and safe to call every launch. -
shouldPrompt
public boolean shouldPrompt()Whether
registerSession()would prompt for a review given the current persisted state and configuration. Exposed mainly for testing and for apps that want to drive the prompt from their own trigger.Returns
true if a prompt is currently due.
-
requestReview
public void requestReview()Immediately asks the user for a review. Uses the native store review prompt when available, otherwise shows the Codename One rating widget. UnlikeregisterSession()this ignores the scheduling thresholds, but it still respects the "already completed" opt out and records the prompt time so the scheduler will not pile on. -
markCompleted
public void markCompleted()Permanently stops the scheduler from prompting again (the user rated the app or chose "don't ask again"). The fallback widget calls this for you; it is exposed for apps that gather a rating through their own UI. -
reset
public void reset()Clears all persisted engagement state (launch count, install date, last prompt time and the completed flag) so the engagement cycle starts over. Mostly useful for testing.
-