This SDK includes a native Android module that enables true OTA bundle updates. The module supports both React Native's old architecture and new architecture (TurboModules).
The module uses React Native's autolinking feature. If you're using React Native 0.60+, the module should be automatically linked.
npm install react-native-ota-sdk
# or
yarn add react-native-ota-sdkcd android
./gradlew clean
cd ..
npx react-native run-androidIf autolinking doesn't work, you can manually link the module:
include ':react-native-ota-sdk'
project(':react-native-ota-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ota-sdk/android')dependencies {
...
implementation project(':react-native-ota-sdk')
}import com.otaupdater.react.OTAPackage;
public class MainApplication extends Application implements ReactApplication {
// ...
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new OTAPackage()); // Add this line
return packages;
}
}The module requires internet permission, which should already be in your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />The native module is automatically used when available. The JavaScript SDK will fall back to file-based updates if the native module is not available.
import { OTAUpdater } from 'react-native-ota-sdk';
// The native module is used automatically for bundle updates
const updater = new OTAUpdater({
apiUrl: 'https://your-api.com',
appId: 'your-app-id',
// ... other config
});If you get "OTANative module is not available":
- Make sure you've rebuilt the app after installing
- Check that
OTAPackageis registered inMainApplication.java - Verify the module is in
node_modules/react-native-ota-sdk/android
If bundles download but don't load:
- Check that the bundle file name matches
index.android.bundle(or your configured name) - Verify the bundle path is correct
- Check logs for errors:
adb logcat | grep OTAUpdater
The module is designed to work with both old and new React Native architectures. For React Native 0.76+ with new architecture enabled, the module will work seamlessly. No additional configuration is needed.