Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review Manager - In App Review #2026

Merged
merged 6 commits into from
Sep 11, 2023

Conversation

Hafizzle
Copy link
Contributor

In-App Review manager logic -

Initial Check:
When determing to request a in-app review, first check if an initial review request has been made.
If no review has been requested before, the app takes note of the current number of user check-ins and proceeds to request a review on the next startup during the next logical break.

Logical Breaks:
After the initial in-app review request, wait for a logical break before potentially asking the user again. This is to ensure we don't pester them :)

Limit on Total Review Requests:
Request a review only up to 5 times. After that, it will not prompt the player for reviews anymore (Unless a user has checked-in 75 times before requesting 5 in-app reviews).

Check-in Limit Since First Review:
If a user has checked in more than 75 times since the very first review was requested, the app won't request another review. This is to ensure that players are not continuously prompted.

Gap Between Review Requests:
Once a review has been requested, wait until the player has checked in at least 5 more times before considering another review request. This ensures a decent gap between consecutive review prompts.

Initial Check:
When determing to request a in-app review, first check if an initial review request has been made.
If no review has been requested before, the app takes note of the current number of user check-ins and proceeds to request a review on the next startup during the next logical break.

Logical Breaks:
After the initial in-app review request, wait for a logical break before potentially asking the user again. This is to ensure we don't pester them :)

Limit on Total Review Requests:
Request a review only up to 5 times. After that, it will not prompt the player for reviews anymore (Unless a user has checked-in 75 times before requesting 5 in-app reviews).

Check-in Limit Since First Review:
If a user has checked in more than 75 times since the very first review was requested, the app won't request another review. This is to ensure that players are not continuously prompted.

Gap Between Review Requests:
Once a review has been requested, wait until the player has checked in at least 5 more times before considering another review request. This ensures a decent gap between consecutive review prompts.
Copy link
Member

@phillipthelen phillipthelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. But looks good so far!

We should also change it to use Hilt for the dependency injection.
Steps for that:

  1. add @Inject to the latent var reviewManager: ReviewManager lines
  2. Remove the initialisations
  3. add the following code to the AppModule.kt file
@Provides
    fun providesReviewManager(@ApplicationContext context: Context): ReviewManager {
        return ReviewManager(context)
    }

That should already be enough to get the ReviewManager available through hilt

if (!shouldQueueReview) {
// First review request has been made, wait for following request (if any)
// to request again in the spirit of asking during a logical break.
sharedPref.edit().putBoolean(SHOULD_QUEUE_REVIEW, true).apply()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use kotlins edit {} shorthand/function


if (initialCheckins == -1) {
// Store the current checkins as the initial value
sharedPref.edit().putInt(INITIAL_CHECKINS_KEY, currentCheckins).apply()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use kotlins edit {} shorthand/function

}

// Save the current checkins after a successful review request
sharedPref.edit().putInt(LAST_REVIEW_CHECKIN_KEY, currentCheckins).apply()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use kotlins edit {} shorthand/function


private fun incrementReviewRequestCount() {
val currentCount = sharedPref.getInt(REVIEW_REQUEST_COUNT_KEY, 0)
sharedPref.edit().putInt(REVIEW_REQUEST_COUNT_KEY, currentCount + 1).apply()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use kotlins edit {} shorthand/function

if (args.type == "gear") {
userViewModel.user.observeOnce(this) { user ->
val totalCheckIns = user?.loginIncentives
if (totalCheckIns != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user?.loginIncentives?.let { totalCheckins ->

}

This would be a slightly more concise/kotlin version


private fun checkForReviewPromptAfterClassSelection() {
userViewModel.user.observeOnce(this) { user ->
val totalCheckIns = user?.loginIncentives ?: return@observeOnce
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version also works (see my other comment. But I think we should stick to one way.

@phillipthelen phillipthelen merged commit 6b950ee into HabitRPG:version/4.3.0 Sep 11, 2023
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants