Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/aravind3566/react-native-in-app-updates/llms.txt

Use this file to discover all available pages before exploring further.

The checkForUpdate function is the single entry point for the react-native-in-app-updates library. Call it at app startup (or at any meaningful moment in your UX) to query the Play Store and, when an update is available, immediately launch the chosen update flow. The function returns a Promise that resolves with a plain string describing the outcome, or rejects with a descriptive error.
This function only works on Android. Calling it on iOS or any other platform will immediately reject with 'This library is only available on Android.' — no native code is invoked.

Signature

import { checkForUpdate, UpdateFlow } from 'react-native-in-app-updates';

function checkForUpdate(
  updateFlow: UpdateFlow,
  isMock?: boolean
): Promise<string>

Parameters

updateFlow
UpdateFlow
required
Determines which Play Store update flow to launch when an update is available. Must be one of the two members of the UpdateFlow enum:
  • UpdateFlow.FLEXIBLE — Starts a background download; the user can continue using the app while the update downloads.
  • UpdateFlow.IMMEDIATE — Launches a full-screen blocking UI; the user must complete (or cancel) the update before returning to the app.
Passing any value outside the enum will cause the promise to reject before any native call is made.
isMock
boolean
default:"false"
When set to true, the native module swaps the real AppUpdateManager for Google Play’s FakeAppUpdateManager. This allows you to test the entire update flow — including download, install, and completion events — without a live Play Store connection or a published update. The fake manager automatically marks an update as available and drives the mock flow to completion.Set this to false (or omit it) in production builds.

Return value

The function returns Promise<string>. On success, the promise resolves to one of the following string values:
No update available
string
The Play Store reports that the installed version is already the latest. No update flow is launched; you can silently ignore this result or show an “up to date” message to the user.
Flexible update started
string
The flexible update flow was successfully launched. The promise resolves immediately after the flow starts — the download continues in the background while the user keeps using the app. Listen for InstallStatus.DOWNLOADED events if you want to prompt the user to apply the update.
Update flow finished
string
The immediate update completed successfully (Activity.RESULT_OK). Because immediate updates restart the app as part of the install, you will typically only see this value during mock testing. In production, the app will have already restarted.

Errors

All errors are thrown as standard JavaScript Error objects (or native bridge rejections) and can be caught in the .catch() handler or a try/catch block.
Source: JavaScript layer, before any native call.Thrown when Platform.OS is not 'android'. The library has no iOS or web implementation; any non-Android platform will trigger this rejection immediately.
// Protect your call site if you share code across platforms
if (Platform.OS === 'android') {
  await checkForUpdate(UpdateFlow.FLEXIBLE);
}
Source: JavaScript layer, before any native call.Thrown when the updateFlow argument is not a member of the UpdateFlow enum. This is a development-time guard — use the enum constants rather than raw strings to avoid this error.
// ❌ Will reject — raw string not accepted
await checkForUpdate('immediate' as any);

// ✅ Correct — use the enum
await checkForUpdate(UpdateFlow.IMMEDIATE);
Source: Native Kotlin module (InAppUpdatesModule.kt).Thrown when reactApplicationContext.currentActivity is null at the time of the call. This can happen if you call checkForUpdate too early in the app lifecycle, before the first Activity has been created, or after the app has been backgrounded and the activity reference has been cleared.Mitigation: Delay the call until after AppState is 'active' and the root component has fully mounted.
Source: Native Kotlin module (InAppUpdatesModule.kt).Thrown when the appUpdateInfo task returned by AppUpdateManager fires its OnFailureListener. Common causes include no internet connectivity, the device not being signed in to a Google account, or the app not being distributed through the Play Store.The rejection message will contain the underlying exception’s localizedMessage for diagnostics.
Source: Native Kotlin module (InAppUpdatesModule.kt).Thrown when the Play Store confirms an update is available but AppUpdateInfo.isUpdateTypeAllowed() returns false for the requested type. Google Play determines eligibility based on criteria such as update staleness, update priority, and app metadata. Consider falling back to the other update flow type when this error occurs.
try {
  await checkForUpdate(UpdateFlow.IMMEDIATE);
} catch (error: any) {
  if (error.code === 'NOT_ALLOWED') {
    // Fall back to the flexible flow
    await checkForUpdate(UpdateFlow.FLEXIBLE);
  }
}
Source: Native Kotlin module (InAppUpdatesModule.kt), via onActivityResult.Thrown when the immediate update UI returns Activity.RESULT_CANCELED — the user tapped the back button or dismissed the update screen. This rejection is only possible with UpdateFlow.IMMEDIATE; the flexible flow resolves immediately after launch and does not wait for user interaction.Decide whether to re-prompt the user, disable features, or simply record the cancellation for analytics.

Usage example

import React, { useEffect } from 'react';
import { Platform } from 'react-native';
import { checkForUpdate, UpdateFlow } from 'react-native-in-app-updates';

export default function App() {
  useEffect(() => {
    async function triggerUpdateCheck() {
      if (Platform.OS !== 'android') return;

      try {
        const result = await checkForUpdate(UpdateFlow.FLEXIBLE);

        switch (result) {
          case 'No update available':
            console.log('App is up to date.');
            break;
          case 'Flexible update started':
            console.log('Downloading update in the background…');
            break;
          case 'Update flow finished':
            console.log('Update complete — app will restart.');
            break;
        }
      } catch (error: any) {
        // Handle specific rejection codes from the native layer
        switch (error.code) {
          case 'NO_ACTIVITY':
            console.warn('No Android activity available — try again later.');
            break;
          case 'UPDATE_CHECK_FAILED':
            console.warn('Could not reach the Play Store:', error.message);
            break;
          case 'NOT_ALLOWED':
            console.warn('Update type not allowed; trying flexible flow.');
            await checkForUpdate(UpdateFlow.FLEXIBLE).catch(console.error);
            break;
          case 'UPDATE_CANCELLED':
            console.info('User dismissed the update prompt.');
            break;
          default:
            console.error('Unexpected error:', error.message);
        }
      }
    }

    triggerUpdateCheck();
  }, []);

  return null; // Replace with your actual app UI
}

Testing with the mock manager

Use isMock: true to exercise both update flows in a local development build without needing a published update on the Play Store:
import { checkForUpdate, UpdateFlow } from 'react-native-in-app-updates';

// FakeAppUpdateManager simulates a flexible download and install
const result = await checkForUpdate(UpdateFlow.FLEXIBLE, true);
// result === "Flexible update started"
Never ship a build to production with isMock set to true. The FakeAppUpdateManager always reports an update as available regardless of the actual Play Store state, which would show a fake update prompt to real users on every app launch.

Linking error

If you see a runtime error such as:
The package 'react-native-in-app-updates' doesn't seem to be linked. Make sure:
- You rebuilt the app after installing the package
- You are not using Expo Go
the native module has not been linked correctly. Ensure you have rebuilt your Android app (npx react-native run-android) after adding the package, and that you are not running inside the Expo Go sandbox, which does not support custom native modules.

Build docs developers (and LLMs) love