How vantuan88291/react-native-ota-hot-update works
Main Components
• React Native Module Core – This is the heart of the project, which interfaces with the JavaScript (JS) layer via React Native’s bridge. It’s implemented in the “src” and “plugin” directories, which include TypeScript definitions and native interfaces.
• Native Code for Android – Found in the “android” directory (and mirrored in parts within the “example/android” folder), this includes Kotlin/Java files such as OtaHotUpdate.kt, OtaHotUpdateModule.kt, and native configuration (e.g., AndroidManifest.xml). Note the two architectures (“newarch” and “oldarch”) that the project supports.
• Update Sources – The system is built to fetch JS bundle updates either directly from a custom server (see DOC_OTA_SERVER.md) or from a Git repository (see DOC_OTA_GIT.md).
• Optional CMS/Administration Panel – Referenced in OTA_CMS.md, this component is used to build a custom admin panel (for example with Strapi) to manage versioning and control OTA updates.
• Example Application – Under the “example” directory, you have a complete demo application that shows how to integrate and use the module in real-world scenarios on both Android and iOS.
Relationships and Interactions
• The native iOS and Android components provide a method (e.g., getBundle() or bundleJS) that is called at runtime when the app starts, replacing the local JS bundle with the updated one.
• The update manager is integrated with external update sources: a server or Git repository, from which the JS bundle is downloaded.
• The CMS or admin panel (if implemented) serves as a control center for update management and versioning.
• In the case of background downloads (detailed in the README for both platforms), show how the native code initiates background tasks and then signals completion back to the app.
Architectural Patterns and Design Principles
• Separation of concerns: Divide components clearly into platform-specific native modules, the React Native bridge, and the external update management systems (server/Git).
• Backward compatibility: Note the dual support for “new architecture” and “old architecture” for Android.
• Modularity: The module’s layered design (separate folders for core JS logic, native integrations, and example apps) reflects clean extensibility and ease of integration.
• Clear abstraction boundaries: The interface provided to React Native apps is abstracted away from the underlying update retrieval and installation logic.
Relevant Technologies and Frameworks
• React Native for cross-platform mobile development.
• Android components built using Kotlin/Java.
• iOS components using Objective-C/Swift, along with bridging headers when needed.
• TypeScript for providing type definitions in the “plugin” and “src” directories.
• Tools like “react-native-blob-util” for download progress (as per the README) and potentially Strapi (or similar) for a CMS solution.
• Build tools include Gradle (Android), Xcode project files (iOS), and JavaScript tooling (babel.config.js, package.json, yarn).
Essential Elements
• Optionally, highlight the architectural pattern (separation of concerns, modular design, and support for multiple native architectures) using annotations or callouts.