in_app_review Flutter Plugin

repository·master·Indexed 18 days ago

https://github.com/britannio/in_app_review

A Flutter plugin providing a unified interface to trigger native in-app review prompts via requestReview() or open app store listings via openStoreListing() across Android, iOS, MacOS, and Windows. It includes tools to check feature availability with isAvailable() and supports platform-specific requirements such as appStoreId for Apple platforms and microsoftStoreId for Windows.

Tokens
2.7K
Snippets
12
Records
16
Agent score
62%

What's inside in_app_review

  1. How the in_app_review platform interface works

    master
    The in_app_review_platform_interface serves as a common contract between the main in_app_review plugin and its platform-specific implementations (e.g., Android, iOS, MacOS). By using this interface, both the plugin and the platform implementations ensure they are adhering to the same API surface, allowing for consistent behavior across different operating systems.
  2. Test `requestReview()` on iOS and MacOS

    master

    iOS

    • requestReview() can be tested on the iOS simulator or a physical device.
    • TestFlight Warning: requestReview() does nothing when testing via TestFlight.
    • Real Reviews: Like Android, real reviews can only be created when the app is in production. The "submit" button is disabled during local testing.
    • Store Listing: openStoreListing() can only be tested on a physical device because the iOS simulator does not include the App Store.

    MacOS

    • You can test the plugin by running your MacOS application locally.
  3. Customize the iOS launch screen assets

    master

    To customize the launch screen for the iOS version of your Flutter app, you can replace the image files located in the LaunchImage.imageset directory with your own assets.

    Alternatively, you can manage these assets using Xcode:

    1. Open your Flutter project's iOS workspace using open ios/Runner.xcworkspace.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog.
    open ios/Runner.xcworkspace
  4. Open the Android example project in Android Studio

    master

    To work with the Android portion of the example app, follow these steps to ensure the Gradle environment is correctly initialized:

    1. Build the example app configuration:
      cd example/
      flutter build apk --config-only
    2. Open Android Studio.
    3. Select Open an existing Android Studio Project.
    4. Navigate to and select in_app_review/example/android/build.gradle.kts.
    5. When the Gradle Sync dialog appears, select OK.
    6. If the Android Gradle Plugin Update dialog appears, select Don't remind me again for this project to maintain the current configuration.
    cd example/
    flutter build apk --config-only
  5. Implement a new platform for in_app_review

    master

    To create a new platform-specific implementation for the in_app_review plugin, you must extend the InAppReviewPlatform class. Once your implementation is ready, you must register it as the default instance by assigning it to InAppReviewPlatform.instance during your plugin registration process.

    // 1. Extend the platform interface
    class MyInAppReview extends InAppReviewPlatform {
      // Implement platform-specific behavior here
    }
    
    // 2. Register the implementation
    InAppReviewPlatform.instance = MyInAppReview();
  6. Test `requestReview()` on Android

    master

    Testing requestReview() on Android is complex because it requires interaction with the Play Store. Running on an emulator or a standard physical device is often insufficient.

    Recommended Testing Workflow:

    1. Build an app bundle.
    2. Upload it via Internal App Sharing.

    Key Notes:

    • Real Reviews: Can only be submitted from the production track. In internal app sharing or other tracks, the "submit" button will be disabled.
    • Application ID: Your app's applicationID must be available at least in the internal testing track.
    • User Account: The user must have the app in their Google Play library (download it via the Play Store using the test account).
    • Primary Account: Ensure the primary account on the device is the one selected in the Play Store.
  7. Trigger the In-App Review prompt with `requestReview()`

    master

    Use requestReview() to show a review pop-up directly within your app, allowing users to leave feedback without leaving the application.

    Important Constraints:

    • Quotas: The underlying platform APIs (Android Play Core and iOS StoreKit) enforce strict quotas. If the quota is exceeded, the pop-up will not appear.
    • Usage Best Practices:
      • Do: Trigger this after a user has had a positive experience (e.g., completing a level or after several days of use).
      • Avoid: Triggering this via a dedicated button or call-to-action, as it will likely fail due to quota restrictions. Also, avoid interrupting users mid-task.
    • Availability: Always check isAvailable() before calling requestReview().
    import 'package:in_app_review/in_app_review.dart';
    
    final InAppReview inAppReview = InAppReview.instance;
    
    if (await inAppReview.isAvailable()) {
        inAppReview.requestReview();
    }
  8. Open the app store listing with `openStoreListing()`

    master

    Use openStoreListing() to redirect users to your app's store page (Google Play Store, Apple App Store, or Microsoft Store).

    Unlike requestReview(), this method is not restricted by a quota and is the recommended way to implement a permanent "Rate Us" button or other call-to-action in your UI.

    Platform-specific requirements:

    • iOS & MacOS: Requires appStoreId (found in App Store Connect under General > App Information > Apple ID).
    • Windows: Requires microsoftStoreId.
    import 'package:in_app_review/in_app_review.dart';
    
    final InAppReview inAppReview = InAppReview.instance;
    
    inAppReview.openStoreListing(appStoreId: '...', microsoftStoreId: '...');
  9. Check platform compatibility and requirements

    master

    Feature Availability

    FunctionAndroidiOSMacOSWindows
    isAvailable()
    requestReview()
    openStoreListing()

    Minimum OS Requirements

    • Android: Android 5 Lollipop (API 21) or higher; Google Play Store must be installed.
    • iOS: iOS 10.3 or higher.
    • MacOS: MacOS 10.14 or higher.
  10. Open the app's store listing

    master

    Use openStoreListing() to redirect the user to the official app store page. This is useful when you want to provide a fallback if the in-app review dialog cannot be shown or if you want to encourage a manual review.

    Platform Behavior and Requirements:

    • Android: Opens the Google Play Store.
    • iOS & MacOS: Opens the App Store with the review screen. Requires the appStoreId parameter.
    • Windows: Opens the Microsoft Store. Requires the microsoftStoreId parameter.
    // For iOS/MacOS
    await InAppReview.instance.openStoreListing(appStoreId: 'YOUR_APP_ID');
    
    // For Windows
    await InAppReview.instance.openStoreListing(microsoftStoreId: 'YOUR_MICROSOFT_STORE_ID');