@vexor-push/react-native-code-push
v0.4.4
Published
Vexor React Native CodePush SDK for self-hosted OTA updates.
Readme
@vexor-push/react-native-code-push
React Native CodePush SDK for Vexor Push. This package combines the app-facing CodePush wrapper and the native OTA bundle loader so mobile apps only install one Vexor package.
Install
pnpm add @vexor-push/react-native-code-pushThe SDK downloads, stores, and installs OTA bundles through the native VexorCodePush bridge. Apps do not need a separate downloader or file-system package.
Configure
import {
checkPendingUpdate,
checkUpdate,
configure,
installUpdate,
notifyApplicationReady,
sync,
} from '@vexor-push/react-native-code-push';
configure({
baseUrl: 'https://cp.example.com',
deploymentKey: '<deployment-key-from-admin>',
binaryVersion: '1.0.0',
clientId: '<stable-device-or-install-id>',
});
await checkPendingUpdate();
await notifyApplicationReady();
const update = await checkUpdate();
if (update.hasUpdate) {
await installUpdate(update);
}
await sync();Pass a stable clientId for device/install metrics. If it is omitted, the SDK generates and stores one through the configured storage adapter.
Device context on reports
Every report carries osVersion and deviceModel, read from
Platform.constants, so the server can say which devices are failing and not
only how many. networkType has no platform API and is left to the app:
import NetInfo from '@react-native-community/netinfo';
import DeviceInfo from 'react-native-device-info';
configure({
// ...
getDeviceContext: async () => ({
networkType: (await NetInfo.fetch()).type,
deviceModel: DeviceInfo.getModel(),
}),
});The result is merged over the platform values, so returning only the fields you have is fine. The hook runs on every report and is never allowed to fail one — a throw or a rejection falls back to the platform values alone, which is also why it must not do anything slow.
Native Loader
The package includes the Vexor native CodePush loader. Keep the standard native setup:
- iOS release builds should return
VexorCodePush.getBundle(). - Android release builds should return
VexorCodePush.bundleJS(applicationContext). - Debug builds should keep using Metro.
Manifest Endpoint
Preferred endpoint:
GET https://cp.example.com/api/ota/key/:deploymentKey/update.json?currentVersion=0&platform=ios&binaryVersion=1.0.0The SDK also supports app/deployment fallback configuration for debugging, but production apps should use deployment keys.
