In-App Updates
Quick Start
Copy the basic status, update-flow, and store-page examples.
Use these examples when you want the shortest working snippets. For screen-level wiring, see App Integration.
Check Update Status
import { getUpdateStatus, isUpdateAvailable } from '@rnforge/react-native-in-app-updates';
const status = await getUpdateStatus();
if (!status.supported) {
console.log('Updates are not supported:', status.reason);
} else if (isUpdateAvailable(status)) {
console.log('Update available:', status.latestStoreVersion ?? status.latestStoreBuild);
} else {
console.log('App is up to date');
}Immediate Update (Android Play)
import {
getUpdateStatus,
startImmediateUpdate,
canStartImmediateUpdate,
} from '@rnforge/react-native-in-app-updates';
const status = await getUpdateStatus();
if (canStartImmediateUpdate(status)) {
const result = await startImmediateUpdate();
console.log('Immediate update result:', result.reason);
}Flexible Update (Android Play)
import {
getUpdateStatus,
startFlexibleUpdate,
completeFlexibleUpdate,
addInstallStateListener,
canStartFlexibleUpdate,
} from '@rnforge/react-native-in-app-updates';
const status = await getUpdateStatus();
if (canStartFlexibleUpdate(status)) {
let subscription: { remove: () => void } | undefined;
subscription = addInstallStateListener((event) => {
if (event.installStatus === 'downloading') {
console.log('Download progress:', event.progress);
}
if (event.installStatus === 'downloaded') {
console.log('Flexible update downloaded');
void completeFlexibleUpdate().finally(() => {
subscription?.remove();
});
}
});
try {
const result = await startFlexibleUpdate();
console.log('Flexible update result:', result.reason);
} catch (error) {
subscription.remove();
throw error;
}
}Keep the subscription alive while the flexible download is active. In a React component, call subscription.remove() from your cleanup function when the screen unmounts.
Store Page Fallback
import {
getUpdateStatus,
openStorePage,
canOpenStorePage,
} from '@rnforge/react-native-in-app-updates';
const storeOptions = {
ios: {
appStoreId: '1234567890',
country: 'us',
},
};
const status = await getUpdateStatus(storeOptions);
if (canOpenStorePage(status)) {
await openStorePage(storeOptions);
}Pass the same iOS options to both calls so the status and store fallback agree.
On Android, openStorePage() can be called without options. On iOS, ios.appStoreId is required.
Common Helpers
| Helper | Use it when |
|---|---|
isUpdateAvailable(status) | You only need to know whether a newer version is available. |
canStartImmediateUpdate(status) | You want to start the blocking Android Play update UI. |
canStartFlexibleUpdate(status) | You want to start a background Android Play update download. |
canCompleteFlexibleUpdate(status) | A flexible update has downloaded and can be installed. |
canOpenStorePage(status) | You want a store-page fallback for unsupported update flows. |
See App Integration for a full React component example that combines these helpers.