react-native-in-app-review

repository·master·Indexed 20 days ago

https://github.com/minasamir11/react-native-in-app-review

A React Native library providing a unified interface to trigger native in-app review and rating flows for iOS (App Store), Android (Google Play), and Huawei (App Gallery). It allows users to rate apps using a 1 to 5 star system and add optional comments on supported platforms. The library includes specific implementations for RequestInAppReview() and requestInAppCommentAppGallery(), along with guidelines for handling platform-specific quotas and testing requirements.

Tokens
4.8K
Snippets
9
Records
18
Agent score
23%

What's inside react-native-in-app-review

  1. Install react-native-in-app-review

    master

    Depending on your user status and package manager, use one of the following methods to install the package.

    For Free Users (Public Registry)

    Use standard installation commands:

    npm install react-native-in-app-review

    OR

    yarn add react-native-in-app-review

    For Paid Users (Latest Version via PayDevs)

    To access the latest version and fixed issues, you must register at paydevs.com and point your package manager to the PayDevs registry.

    Using npm or pnpm:

    npm set registry https://npm.paydevs.com/
    npm login
    npm update

    Using yarn:

    yarn config set registry https://npm.paydevs.com/
    yarn login
    yarn upgrade
    npm install react-native-in-app-review
  2. Configure iOS and Android linking

    master

    React Native 0.60 and above

    Linking is automatic. After installation, ensure you run:

    npx pod-install

    React Native 0.59 and below

    You must manually link the library using:

    react-native link react-native-in-app-review

    iOS Manual Installation (CocoaPods)

    Add the following to your Podfile and run pod install:

     pod 'react-native-in-app-review', :path => '../node_modules/react-native-in-app-review'

    Android Manual Installation

    1. android/settings.gradle:
    include ':react-native-in-app-review'
    project(':react-native-in-app-review').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-in-app-review/android')
    1. android/app/build.gradle (for version >= 5.0.0):
    dependencies {
       implementation project(':react-native-in-app-review')
    }
    1. android/gradle.properties (for AndroidX migration):
    android.useAndroidX=true
    android.enableJetifier=true
    1. android/app/src/main/java/your/package/MainApplication.java:
    import com.ibits.react_native_in_app_review.AppReviewPackage;
    
    // Inside getPackages()
    @Override
    protected List<ReactPackage> getPackages() { 
        return Arrays.asList(
                new MainReactPackage(),
                new AppReviewPackage()
        );
    }
  3. Best practices for iOS System Rating and Review Prompts

    master

    When using the iOS system rating feature, follow these guidelines to ensure a good user experience and respect system limitations:

    System Behavior

    • The system displays an in-app prompt for a rating and optional written review.
    • Frequency Limit: The system automatically limits the display of the prompt to three occurrences per app within a 365-day period.
    • Users can opt out of these prompts globally in their iOS Settings.

    When to Request a Review

    • Demonstrate Engagement: Prompt users after they complete a task (e.g., finishing a game level or a productivity task). Never ask for a rating on the first launch or during onboarding.
    • Avoid Interruptions: Do not prompt during time-sensitive or stressful tasks. Look for logical pauses.
    • Don't be a pest: Allow at least one to two weeks between requests and only prompt after new engagement is shown.
    • Avoid Manual Triggers: Do not use custom buttons or UI controls to trigger the request. Because the system limits how often prompts occur, triggering it via a button might result in the prompt not being displayed at all.
  4. Google Play In-App Review requirements and testing

    master

    Device Requirements

    In-app reviews work on:

    • Android devices (phones and tablets) running Android 5.0 (API level 21) or higher with Google Play Store installed.
    • Chrome OS devices with Google Play Store installed.

    Testing Integration

    You do not need to publish your app to production to test. You can use:

    • Internal test tracks
    • Internal app sharing

    Note: Your applicationID must be available in at least the internal testing track for testing to work.

  5. Best practices for requesting in-app reviews

    master

    To ensure a positive user experience and avoid API limitations, follow these guidelines:

    • Timing: Trigger the review flow after a user has experienced enough of your app to provide meaningful feedback.
    • Frequency: Do not prompt users excessively. Excessive prompting leads to user frustration and may hit API quotas.
    • Avoid Leading Questions: Do not ask questions before or during the review process (e.g., "Do you like the app?" or "Would you rate us 5 stars?"). Let the system handle the rating interface.
    • Handle Quotas Gracefully: Google Play enforces a quota on how often a review dialog is shown. Do not rely on a specific UI element (like a 'Rate Us' button) to trigger the flow, as the dialog may not appear if the user has reached their quota.
  6. Troubleshoot Huawei App Gallery in-app comments

    master

    If the in-app comment functionality is not working on Huawei devices, ensure the following requirements are met:

    Device Requirements

    • AppGallery Version: Must be 11.3.2.302 or later.
    • HMS Core: The HMS Core (APK) must be installed on the device.

    Application & Audience Restrictions

    • Scope: The function is only available for apps released on AppGallery outside of the Chinese mainland.
    • User Authentication: Users must be signed in to AppGallery using a HUAWEI ID.
    • Engagement Threshold: The pop-up only appears for users who have opened the app 10 or more times within the last three months since the API was called.
    • Frequency Limits:
      • If a user has already submitted a rating/comment for the current app version, the pop-up will not show again for that version.
      • To see the pop-up again, the user must update to a later version AND have not submitted a rating/comment for more than a calendar year.
    • User Settings: If a user has disabled app comment notifications in AppGallery (Me > Settings), the pop-up will not be displayed.
  7. Troubleshoot Google Play Review popup visibility

    master

    If you follow all guidelines but the popup still does not show, try these steps:

    1. Ensure the latest Google Play Store update is installed.
    2. Avoid GSuite IDs: The popup may not work if signed in with a GSuite ID. Switch to a standard @gmail address.
    3. Single Account: Ensure there is only one Google account on the test device.
    4. Tester Status: Ensure the user is explicitly added as a tester if using a testing track.
    5. Clear Data: Clear CACHE and STORAGE from the Google Play Store app.
    6. Remove Existing Rating: Remove any existing app ratings in the Play Store.
    7. Reinstall: Remove the app and reinstall it after performing the steps above.
  8. Troubleshoot Google Play In-App Review issues

    master

    If the in-app review dialog fails to appear, check the following common issues and solutions:

    IssueSolution
    App is not publishedEnsure your applicationID is available in an internal testing track.
    User account can't reviewThe app must be in the user's Google Play library. Download the app from the Play Store using that account.
    Primary account not selectedEnsure the primary account is the one selected in the Play Store when multiple accounts exist.
    Protected user accountAvoid enterprise accounts; use a standard @gmail account instead.
    User already reviewedDelete the existing review directly from the Google Play Store.
    Quota reachedUse an internal test track or internal app sharing to bypass quota limits during testing.
    Play Store/Services issueThis can happen if the Play Store was sideloaded. Use a device with a valid, non-sideloaded version of Play Store and Play Services.
  9. Mock react-native-in-app-review for Jest tests

    master

    Since this is a native module, you must mock it to run Jest tests. You may need to mock the return value as a resolved Promise to avoid TypeError: Cannot read property 'then' of undefined.

    // Option 1: In a __mocks__/react-native-in-app-review.js file
    module.exports = {
      RequestInAppReview: jest.fn().mockImplementation(() => {
        return Promise.resolve();
      }),
      isAvailable: jest.fn(),
    };
    
    // Option 2: In a jest.setup.js file
    jest.mock('react-native-in-app-review', () => ({
      RequestInAppReview: jest.fn().mockImplementation(() => {
        return Promise.resolve();
      }),
      isAvailable: jest.fn(),
    }));
  10. Use Huawei App Gallery In-App Comment API

    master

    To use Huawei App Gallery reviews, ensure you have integrated HMS into your project, your app is officially released on AppGallery, and users are using AppGallery 11.3.2.302 or later with HUAWEI IDs.

    Use requestInAppCommentAppGallery() to trigger the UI. A resultCode of 102 or 103 indicates a rating or comment was successfully submitted.

    import InAppReview from 'react-native-in-app-review';
    
    InAppReview.requestInAppCommentAppGallery()
      .then((resultCode) => {
        // resultCode 102 or 103 means Rating or Comment submitted
        console.log('in app comment app gallery', resultCode);
      })
      .catch((error) => {
        console.log(error);
      });