Skip to content

⭐️ A non-invasive and friendly way to remind users to review or rate an Android app.

License

Notifications You must be signed in to change notification settings

theappcapital/SiriusRating-Android

Repository files navigation

SiriusRating Android

See: https://github.com/theappcapital/SiriusRating-iOS for iOS.

Kotlin API Maven Central

github-banner

A non-invasive and friendly way to remind users to review an Android app.

Features

  • Automatically adapts to your theme
  • Jetpack Compose support
  • Dark mode support
  • Unit tested
  • Configurable rating conditions
  • Write your own rating conditions to further stimulate positive reviews.
  • Modern design
  • Non-invasive approach
  • Recurring prompts that are configurable using back-off factors
  • Option to create your own prompt style

Setup

Configure a SiriusRating shared instance, typically in your MainActivity or your app's initializer.

Simple One-line Setup

In the onCreate() function in MainActivity:

SiriusRating.setup(this)

For example:

// ...
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    
    // ...
    SiriusRating.setup(this)
}

By default, the user will be prompted to rate the app when the following conditions are met:

  • The app has been installed for at least 30 days,
  • The user has opened the app at least 15 times, and
  • The user has completed 20 significant events.

If the user selects 'Remind me later,' they will be prompted again after 7 days. If the user declines the prompt, they will be prompted again after 30 days, with a back-off factor of 2. This means that if the user declines a second time, they will be prompted again in 60 days, a third time in 120 days, and so on.

Installation

Gradle

To integrate SiriusRating into your Android project, specify it in your build.gradle.kts:

dependencies {
    //...
    implementation("com.theappcapital.siriusrating-android:1.0.2")
}

Or build.gradle:

dependencies {
    //...
    implementation 'com.theappcapital.siriusrating-android:1.0.2'
}

Usage

Significant event

A significant event defines an important event that occurred in your app. In a time tracking app it might be that a user registered a time entry. In a game, it might be completing a level.

SiriusRating.instance().userDidSignificantEvent()

SiriusRating will validate the conditions after each significant event and prompt the user if all conditions are satisfied.

Test request prompt

To see how the request prompt will look like in your app simply use the following code.

// For test purposes only.
SiriusRating.instance().showRequestPrompt()

Styles

StyleOneRequestPromptPresenter (light, default) StyleOneRequestPromptPresenter (dark, default)
Style One (light) Style Two (Dark)
StyleTwoRequestPromptPresenter (light) StyleTwoRequestPromptPresenter (dark)
Style Two (light) Style Two (dark)

Rating conditions

The rating conditions are used to validate if the user can be prompted to rate the app. The validation process happens after the user did a significant event (userDidSignificantEvent()) or if configured when the app was opened. The user will be prompted to rate the app if all rating conditions are satisfied (returning true).

Rating Condition Description
EnoughAppSessionsRatingCondition Validates whether the app has been launched or brought into the foreground a sufficient number of times.
EnoughDaysUsedRatingCondition Validates whether the app has been in use for a sufficient duration (in days).
EnoughSignificantEventsRatingCondition Validates whether the user has completed enough significant events.
NotDeclinedToRateAnyVersionRatingCondition Validates that the user hasn’t declined to rate any version of the app. If declined, it checks whether enough time has passed since the initial decline before prompting again.
NotPostponedDueToReminderRatingCondition Validates whether the user has opted to be reminded later. If so, it checks if the required number of days has passed to prompt again.
NotRatedCurrentVersionRatingCondition Validates whether the user has already rated the current version of the app. The user won’t be prompted again if they’ve already rated this version.
NotRatedAnyVersionRatingCondition Validates that the user hasn’t rated any version of the app. If the user has previously rated the app, it checks whether enough time has passed since their last rating before prompting again.

Customization

Custom Configuration

SiriusRating.setup(activity) {
    debugEnabled(true)
    canPromptUserToRateOnLaunch(true)
    requestToRatePromptPresenter(StyleTwoRequestToRatePromptPresenter(activity))
    ratingConditions(
        EnoughDaysUsedRatingCondition(totalDaysRequired = 0),
        EnoughAppSessionsRatingCondition(totalAppSessionsRequired = 0),
        EnoughSignificantEventsRatingCondition(significantEventsRequired = 5),
        // Essential rating conditions below: Ensure these are included to prevent the prompt from appearing continuously.
        NotPostponedDueToReminderRatingCondition(totalDaysBeforeReminding = 14),
        NotDeclinedToRateAnyVersionRatingCondition(daysAfterDecliningToPromptUserAgain = 30, backOffFactor = 2.0, maxRecurringPromptsAfterDeclining = 2),
        NotRatedCurrentVersionRatingCondition(appVersionProvider = PackageInfoCompatAppVersionProvider(context = activity)),
        NotRatedAnyVersionRatingCondition(daysAfterRatingToPromptUserAgain = 240, maxRecurringPromptsAfterRating = Int.MAX_VALUE)
    )
    didAgreeToRateHandler {
        //...
    }
    didOptInForReminderHandler {
        //...
    }
    didDeclineToRateHandler {
        //...
    }
}

Custom rating conditions

You can write your own rating conditions in addition to the current rating conditions to further stimulate positive reviews.

class GoodWeatherRatingCondition(
    private val weatherRepository: WeatherRepository
) : RatingCondition {

    override fun isSatisfied(dataStore: DataStore): Boolean {
        // Only show the rating prompt when it's sunny outside.
        return weatherRepository.getWeather().isSunny
    }
}

To make use of the new rating condition simply add it to the list.

SiriusRating.setup(this) {
    ratingConditions(
        // ...,
        GoodWeatherRatingCondition(weatherRepository = WeatherDataRepository())
    )
}

Change texts

You can override the texts in strings.xml.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="sirius_rating.text_view_title.text">Rate %1$s</string>
    <string name="sirius_rating.text_view_duration.text">(duration: less than 10 seconds)</string>
    <string name="sirius_rating.text_view_description.text">If you enjoy using %1$s, would you mind taking a moment to rate it? Thanks for your support!</string>
    <string name="sirius_rating.button_rate.text">Rate %1$s</string>
    <string name="sirius_rating.button_decline.text">No, thanks</string>
    <string name="sirius_rating.button_opt_in_for_reminder.text">Remind me later</string>
</resources>

Change colors

SiriusRating will automatically use your primary theme colors. You can manually customize them in themes.xml.

For Google Material theme:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.YourApp" parent="android:Theme.Material.Light.NoActionBar">
        <item name="colorPrimary">@color/black</item>
        <item name="colorOnPrimary">@color/white</item>
    </style>
</resources>

Or if you're using App Compat theme:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.YourApp" parent="Theme.AppCompat.NoActionBar">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorControlNormal">@color/white</item>
    </style>
</resources>

Change app name

SiriusRating will automatically use the app_name in the strings.xml. If you don't want to use this name you can set it manually.

SiriusRating.setup(activity) {
    requestToRatePromptPresenter(StyleTwoRequestToRatePromptPresenter(activity, appName = "App Name"))
}

License

SiriusRating is released under the MIT license. See LICENSE for details.