# Class AppReview

java.lang.Object
com.codename1.appreview.AppReview

public class AppReview extends Object

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:

1. 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.

2. Scheduled -- configure the engagement heuristics once and call `registerSession()` on every app start. `AppReview` keeps a small amount of state in `Preferences` (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(storeUrl)   // the listing for THIS platform's store
            .setSupportEmail("support@example.com")
            .registerSession();

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static AppReview`
  `getInstance()`
  The shared `AppReview` instance.
  `void`
  `markCompleted()`
  Permanently stops the scheduler from prompting again (the user rated the app or chose "don't ask again").
  `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.
  `void`
  `requestReview()`
  Immediately asks the user for a review.
  `void`
  `reset()`
  Clears all persisted engagement state (launch count, install date, last prompt time and the completed flag) so the engagement cycle starts over.
  `AppReview`
  `setDaysBetweenPrompts(int daysBetweenPrompts)`
  The minimum number of days between two consecutive review prompts shown by the scheduler.
  `AppReview`
  `setFeedbackListener(FeedbackListener feedbackListener)`
  Registers a listener that intercepts the outcome of the fallback rating widget so feedback can be delivered through your own channel.
  `AppReview`
  `setHighRatingThreshold(int highRatingThreshold)`
  The lowest star value (1-5) that is still considered a positive rating in the fallback widget.
  `AppReview`
  `setMinimumDaysInstalled(int minimumDaysInstalled)`
  The number of days that must elapse after the first recorded launch before the scheduler will prompt for a review.
  `AppReview`
  `setMinimumLaunches(int minimumLaunches)`
  The number of app launches that must accumulate before the scheduler in `registerSession()` will prompt for a review.
  `AppReview`
  `setStoreUrl(String storeUrl)`
  The store URL opened by the fallback widget for a positive rating (and used when no native prompt is available).
  `AppReview`
  `setSupportEmail(String supportEmail)`
  The support e-mail address used by the fallback widget to collect feedback for low ratings when no `FeedbackListener` handled it.
  `boolean`
  `shouldPrompt()`
  Whether `registerSession()` would prompt for a review given the current persisted state and configuration.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getInstance

    public static AppReview getInstance()

    The shared `AppReview` instance.

    ###### Returns

    the singleton used by the whole application.

  - ### setMinimumLaunches

    public AppReview setMinimumLaunches(int minimumLaunches)

    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

    public AppReview setMinimumDaysInstalled(int minimumDaysInstalled)

    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

    public AppReview setDaysBetweenPrompts(int daysBetweenPrompts)

    The minimum number of days between two consecutive review prompts shown by the scheduler. Defaults to 30.

    ###### Returns

    this instance for chaining.

  - ### setHighRatingThreshold

    public AppReview setHighRatingThreshold(int highRatingThreshold)

    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

    public AppReview setStoreUrl(String storeUrl)

    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. The fallback opens this URL when no native review prompt is available, so it has to be the listing for the store the app was installed from. There is one slot, so an app shipping to more than one store picks the URL at runtime rather than hard-coding a single vendor's link.

  - ### setSupportEmail

    public AppReview setSupportEmail(String supportEmail)

    The support e-mail address used by the fallback widget to collect feedback for low ratings when no `FeedbackListener` handled it. When null and no listener is set, the feedback step is skipped.

    ###### Returns

    this instance for chaining.

  - ### setFeedbackListener

    public AppReview setFeedbackListener(FeedbackListener feedbackListener)

    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 the `start` lifecycle 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. Unlike `registerSession()` 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.