This document describes the implementation of Google Play In-App Review integration for the OnlineGo app.
The review prompt system follows Google's guidelines and prompts users to rate the app after they win a game, with configurable timing and cooldown periods.
- Configurable timing: Users are prompted after using the app for a configurable number of days (default: 7 days)
- Cooldown period: 2-week cooldown after dismissal to avoid being intrusive
- Game win detection: Prompts are triggered only after the user wins a game
- Google Play In-App Review: Uses the official Google Play In-App Review API when available
- Fallback support: Falls back to Play Store redirect if in-app review fails
- Analytics tracking: Comprehensive analytics events for review prompt interactions
- Google guidelines compliance: Follows Google's best practices for review prompts
- ReviewPromptRepository: Manages review prompt state using DataStore
- ReviewPromptManager: Handles the review flow and Google Play integration
- GameViewModel: Integrates review prompts with game win detection
- GameUI: UI layer that triggers review prompts
The system is configured with the following constants in ReviewPromptRepository:
private const val DAYS_BEFORE_FIRST_PROMPT = 7L // Configurable: 7 days
private const val COOLDOWN_DAYS = 14L // 2 weeks cooldownThe following analytics events are tracked:
review_prompt_shown: When a review prompt is displayedreview_prompt_dismissed: When user dismisses the promptreview_prompt_rated: When user rates the appreview_prompt_completed_in_app: When in-app review is completedreview_prompt_dismissed_in_app: When in-app review is dismissedreview_prompt_redirected_to_play_store: When falling back to Play Storereview_prompt_redirected_to_browser: When falling back to browserapp_rated_externally: When app is marked as rated externallyreview_state_reset: When review state is reset (testing)
The system tracks the following state:
app_first_launch_time: When the app was first launchedlast_review_prompt_time: When the last review prompt was shownreview_prompt_dismissed: Whether the user dismissed the promptreview_prompt_rated: Whether the user has rated the app
- Game Win Detection: In
GameViewModel.onGameChanged(), when a game finishes and the player wins - UI Trigger: In
GameUI.kt, aLaunchedEffectmonitorsshouldShowReviewPromptstate - Dependency Injection: Added to Koin modules for proper dependency management
The review prompt is automatically triggered when:
- User wins a game
- App has been used for the configured number of days
- Not in cooldown period
- User hasn't already rated the app
For testing purposes, you can use the following methods:
// Force show review prompt (bypasses all conditions)
reviewPromptManager.forceShowReviewPrompt(activity)
// Reset review state (for testing)
reviewPromptManager.resetReviewState()
// Mark app as rated externally
reviewPromptManager.markAppAsRated()To modify the timing, update the constants in ReviewPromptRepository:
private const val DAYS_BEFORE_FIRST_PROMPT = 7L // Change this value
private const val COOLDOWN_DAYS = 14L // Change this valueThe implementation follows Google's guidelines:
- Timing: Prompts are shown at natural break points (after game wins)
- Frequency: Respects cooldown periods to avoid being intrusive
- User Experience: Uses Google Play In-App Review API when available
- Fallback: Gracefully falls back to Play Store redirect
- Analytics: Tracks user interactions for optimization
- First-time user: Should not be prompted until after 7 days
- Game win: Should be prompted after winning a game (if conditions are met)
- Dismissal: Should not be prompted again for 2 weeks after dismissal
- Rating: Should not be prompted again after rating
- Cooldown: Should respect 2-week cooldown period
You can check the current review prompt state:
val state = reviewPromptRepository.getReviewPromptState()
// Returns: ReviewPromptState with all current values- Google Play Core Library (version 2.0.2)
- Firebase Analytics (for event tracking)
- Firebase Crashlytics (for error reporting)
- DataStore (for state persistence)
Potential improvements:
- A/B testing for different timing configurations
- More sophisticated user engagement metrics
- Integration with user feedback systems
- Custom review prompt UI for better branding