### Installation Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Instructions on how to install the Pushy CLI globally. ```APIDOC ## Installation ### Description Installs the Pushy CLI globally using npm. ### Command ```bash $ npm install -g react-native-update-cli ``` ``` -------------------------------- ### Run Example Scripts Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli_module.md Instructions for running example scripts located in the project's `example/` directory. These scripts demonstrate module registration, workflow execution, and enhanced workflow usage. ```bash # 模块注册和执行示例 npx ts-node example/scripts/register-modules.ts # 工作流演示 npx ts-node example/scripts/workflow-demo.ts # 增强工作流演示 npx ts-node example/scripts/enhanced-workflow-demo.ts ``` -------------------------------- ### Create Expo Entry File for Pushy Bundling Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/publish.mdx Provides an example of an index.js file for Expo projects to resolve bundling errors with Pushy. This file acts as an entry point, referencing the framework's own entry file, which is necessary when the framework does not provide a default index.js. ```javascript import "expo-router/entry"; ``` -------------------------------- ### Install Pushy SDK and CLI Source: https://context7.com/reactnativecn/pushy-site/llms.txt Installs the Pushy SDK and command-line tools globally and within the project. For iOS projects, it also installs necessary pod dependencies. ```bash # Install CLI globally npm i -g react-native-update-cli # Install SDK in project npm i react-native-update # Install iOS pod dependencies cd ios && pod install ``` -------------------------------- ### Call Pushy API with Token (Bash) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api-token.mdx Demonstrates how to make a GET request to the Pushy API's app list endpoint using an API Token. The token is passed in the 'x-api-token' request header. Ensure you replace 'YOUR_API_TOKEN' with your actual token. ```bash curl -X GET "https://update.reactnative.cn/api/app/list" \ -H "x-api-token: YOUR_API_TOKEN" ``` -------------------------------- ### Android Manifest Permissions for APK Installation Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Specifies the necessary permissions in `AndroidManifest.xml` for the `downloadAndInstallApk` function to work. `REQUEST_INSTALL_PACKAGES` is required for installing APKs. `WRITE_EXTERNAL_STORAGE` is needed for compatibility with Android versions below 7.0. Note that some app stores may reject apps with these permissions. ```xml ``` -------------------------------- ### Download and Install APK with downloadAndInstallApk() in React Native (Android) Source: https://context7.com/reactnativecn/pushy-site/llms.txt Downloads and installs an APK file, specifically for Android, to guide users through updating native packages when they have expired. This requires configuring installation permissions in `AndroidManifest.xml`. It's used when a critical native update is needed. ```javascript import { useUpdate } from "react-native-update"; import { Platform, Alert } from "react-native"; import { useEffect } from "react"; function NativeUpdateHandler() { const { downloadAndInstallApk, updateInfo } = useUpdate(); useEffect(() => { if (updateInfo?.expired && Platform.OS === "android") { Alert.alert( "Version Expired", "The current version is no longer supported. Please update to the latest version.", [ { text: "Update Now", onPress: () => downloadAndInstallApk(updateInfo.downloadUrl) } ], { cancelable: false } ); } }, [updateInfo]); return null; } // AndroidManifest.xml requires the following permissions: // // (for Android 7.0 and below) ``` -------------------------------- ### Install react-native-update-cli Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Installs the react-native-update-cli globally using npm. This command is the first step to using the Pushy CLI for managing hot updates. ```bash npm install -g react-native-update-cli ``` -------------------------------- ### Download and Install APK (JavaScript) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Downloads an APK file from a given URL and attempts to install it directly. This function's success is not guaranteed due to system security restrictions. If a download or installation fails within the current app session, subsequent calls will silently fail without retrying. Requires `REQUEST_INSTALL_PACKAGES` permission in `AndroidManifest.xml`. ```javascript await downloadAndInstallApk('http://example.com/app.apk'); ``` -------------------------------- ### Publish Hot Update in GitHub Actions (YAML) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api-token.mdx An example GitHub Actions workflow file demonstrating how to publish a hot update using Pushy. It sets up Node.js, installs dependencies including the 'react-native-update-cli', and uses the 'PUSHY_API_TOKEN' environment secret to authenticate the 'pushy bundle' command. ```yaml # .github/workflows/publish.yml name: Publish Hot Update on: push: branches: [main] jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' - name: Install dependencies run: npm install && npm i -g react-native-update-cli - name: Publish update env: PUSHY_API_TOKEN: ${{ secrets.PUSHY_API_TOKEN }} run: pushy bundle --platform android ``` -------------------------------- ### Get Current Hot Update Version Info (JavaScript Example) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Retrieves information about the currently applied hot update. If no hot update has been applied, it returns an empty object. For versions v10.31.2 and later, the `currentVersionInfo` property from `useUpdate` can be used directly. ```javascript const info = await getCurrentVersionInfo(); // info might look like: // { // name: '1.0.3-rc', // description: '添加聊天功能\n修复商城页面BUG', // metaInfo: '{"silent":true}', // } ``` -------------------------------- ### Check for Updates (JavaScript Example) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Triggers an update check and returns `updateInfo`. Prior to v10.26.0, `checkUpdate` had no return value, and `updateInfo` from `useUpdate` was recommended. The return value indicates if the app is expired, up-to-date, or if an update is available. ```javascript { expired: true, downloadUrl: 'http://appstore/downloadUrl', } ``` ```javascript { upToDate: true, } ``` ```javascript { update: true, name: '1.0.3-rc', hash: 'hash', description: '添加聊天功能\n修复商城页面BUG', metaInfo: '{"silent":true}', pdiffUrl: 'http://update-packages.reactnative.cn/hash', diffUrl: 'http://update-packages.reactnative.cn/hash', } ``` -------------------------------- ### Get Current Hot Update Version Info in React Native Source: https://context7.com/reactnativecn/pushy-site/llms.txt Retrieves information about the currently installed hot update version, including its name, description, and metadata. For versions 10.31.2 and above, the `currentVersionInfo` property can be accessed directly. This function is part of the `react-native-update` library. ```javascript import { useUpdate } from "react-native-update"; import { Text, View } from "react-native"; function VersionInfo() { const { currentVersionInfo, currentHash, packageVersion } = useUpdate(); return ( 原生版本: {packageVersion} 热更Hash: {currentHash || "无"} {currentVersionInfo && ( <> 热更版本: {currentVersionInfo.name} 更新说明: {currentVersionInfo.description} 元信息: {currentVersionInfo.metaInfo} )} ); } ``` -------------------------------- ### Pushy Constructor Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Initializes a new Pushy instance with the provided options. This is the main entry point for using the Pushy SDK. ```APIDOC ## JavaScript Methods ### `new Pushy(options: PushyOptions)` Creates a Pushy hot update service instance. The constructor accepts the following options: #### `PushyOptions` Interface - **`appKey`** (string) - Required - Your application's unique key, obtained via `pushy createApp` or `selectApp` commands, or from the web management console. - **`logger`** (function) - Optional - A custom logging function that can also be used for reporting statistics. It receives an object with `type` (EventType) and `data` (EventData). - **`checkStrategy`** (string | null) - Optional - Determines when to automatically check for updates. Options include `"onAppStart"`, `"onAppResume"`, `"both"` (default), or `null` to disable automatic checks (requires v10.4.2+). - **`updateStrategy`** (string | null) - Optional - Controls how updates are downloaded and applied. Options include `"alwaysAlert"`, `"alertUpdateAndIgnoreError"` (default for production), `"silentAndNow"`, `"silentAndLater"`, or `null` to disable automatic updates and allow custom handling. - **`autoMarkSuccess`** (boolean) - Optional - If `true` (default), automatically marks the hot update as successful after restarting the app. Manual marking is generally not recommended. - **`dismissErrorAfter`** (number) - Optional - Automatically clears the last error message after a specified number of milliseconds. Defaults to not clearing. - **`debug`** (boolean) - Optional - If `true`, enables checking for hot updates in development environments (requires v10.4.2+). Note that updates can be checked and downloaded in debug mode, but actual application requires a release build. - **`throwError`** (boolean) - Optional - If `true`, errors thrown during `checkUpdate` and `downloadUpdate` will be thrown as exceptions (requires v10.15.2+). Errors can still be accessed via `lastError`. - **`beforeCheckUpdate`** (function) - Optional - A callback function executed before checking for updates. Returning `false` will cancel the check (requires v10.12.0+). - **`beforeDownloadUpdate`** (function) - Optional - A callback function executed before downloading an update. Returning `false` will cancel the download (requires v10.12.0+). - **`afterDownloadUpdate`** (function) - Optional - A callback function executed after an update has been downloaded. Returning `false` will prevent the built-in update strategy from proceeding (requires v10.27.0+). - **`onPackageExpired`** (function) - Optional - A callback function executed when the native package has expired. Returning `false` will prevent the built-in update strategy from proceeding (requires v10.28.2+). #### `EventType` Enum - `"rollback"`: Update failed, rolled back after restart. - `"errorChecking"`: Error occurred during update check. - `"checking"`: Checking for updates. - `"downloading"`: Downloading update. - `"downloadSuccess"`: Update downloaded successfully. - `"errorUpdate"`: Update failed. - `"markSuccess"`: Update marked as successful. - `"downloadingApk"`: Downloading APK. - `"rejectStoragePermission"`: Storage permission for APK download rejected. - `"errorStoragePermission"`: Error requesting storage permission for APK download. - `"errorDownloadAndInstallApk"`: Error downloading and installing APK. #### `EventData` Interface - **`currentVersion`** (string) - The hash of the currently applied hot update. Empty if no update has been applied. - **`cInfo`** (object) - Client information: - `rnu` (string): Current `react-native-update` version. - `rn` (string): Current React Native version. - `os` (string): Operating system and version. - `uuid` (string): User identifier. - **`packageVersion`** (string) - The version of the client's native package. - **`buildTime`** (number) - Build timestamp. - **`message`** (string) - Error message, if applicable. - **`rolledBackVersion`** (string) - The version hash that was rolled back to, if applicable. - **`newVersion`** (string) - The hash of the new version that failed to update, if applicable. - **`[key: string]`** (any) - Other miscellaneous data. ### Request Example ```javascript import Pushy from 'pushy-sdk'; const pushy = new Pushy({ appKey: 'YOUR_APP_KEY', checkStrategy: 'both', updateStrategy: 'alertUpdateAndIgnoreError', logger: ({ type, data }) => { console.log(`Pushy Event: ${type}`, data); } }); ``` ### Response This method does not return a value directly but initializes the Pushy service. ``` -------------------------------- ### pushy apps Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Lists all created applications. ```APIDOC ## pushy apps ### Description Lists all created applications. This operation can also be performed on the web management interface. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Command Line Arguments - **platform** (ios|android|harmony) - Optional - Filters applications by platform. ### Response #### Success Response - **apps** (array) - A list of application objects. - **appId** (string) - The ID of the application. - **name** (string) - The name of the application. - **platform** (string) - The platform of the application. #### Response Example ```json { "apps": [ { "appId": "app123", "name": "My App", "platform": "android" } ] } ``` ``` -------------------------------- ### Switch to Downloaded Version on Next Launch (JavaScript) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Schedules the downloaded version to be loaded upon the next application launch. Similar to `switchVersion`, ensure `await downloadUpdate()` has been called and completed before relying on this function. Do not depend on `progress` for completion status. ```javascript switchVersionLater(); ``` -------------------------------- ### pushy createApp Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Creates a new application and binds it to the current project. ```APIDOC ## pushy createApp ### Description Creates a new application and immediately binds it to the current project. This operation can also be performed on the web management interface. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Command Line Arguments - **platform** (ios|android|harmony) - Required - The target platform for the app. - **name** (string) - Required - The name of the application. - **downloadUrl** (string) - Optional - The download URL for the application's installation package. ### Response #### Success Response - **appId** (string) - The ID of the newly created application. - **message** (string) - A success message. #### Response Example ```json { "appId": "app123", "message": "Application created and bound successfully." } ``` ``` -------------------------------- ### Switch to Downloaded Version Immediately (JavaScript) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Restarts the application and loads the version that has already been downloaded. It is crucial to call `await downloadUpdate()` before invoking this function and not rely on the `progress` data to determine download completion. ```javascript switchVersion(); ``` -------------------------------- ### Initialize Pushy Service with Options (TypeScript) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/api.mdx Demonstrates how to create a new instance of the Pushy hot update service using the `Pushy` constructor. It includes explanations for various configuration options such as `appKey`, `logger`, `checkStrategy`, and `updateStrategy`, which control the behavior of automatic updates and error handling. ```typescript interface PushyOptions { // Required, obtained via pushy createApp or selectApp command, or from the web management console appKey: string; // Custom log output, can also be used for reporting statistics logger?: ({ type, data }: { type: EventType; data: EventData }) => void; // Strategy for triggering automatic update checks checkStrategy?: | "onAppStart" // Only on app start | "onAppResume" // Only when the app resumes from the background | "both"; // Default value, includes both scenarios | null; // Do not automatically check for updates, must call checkUpdate manually, requires v10.4.2+ // Strategy for automatically downloading and applying updates updateStrategy?: | "alwaysAlert" // Default in debug environment (__DEV__), uses system default alert page for hot updates and shows errors | "alertUpdateAndIgnoreError" // Default in production environment, uses system default alert page for hot updates but suppresses error messages | "silentAndNow" // Silently downloads and applies hot updates immediately | "silentAndLater"; // Silently downloads hot updates, applies them only after the user exits and restarts the app | null; // Do not automatically download and apply updates, choose this option for custom update interfaces // Whether to automatically mark the update as successful after a hot update restart, defaults to true // Generally not recommended to manually mark autoMarkSuccess?: boolean; // Whether to automatically clear the last error after a specified number of milliseconds, defaults to not clearing dismissErrorAfter?: number; // Whether to check for hot updates in the development environment, defaults to false. Enable this option to debug hot updates in development. // Even with this option enabled, hot updates can only be checked and downloaded, not actually applied. Actual application requires a release build. // Requires v10.4.2+ debug?: boolean; // Whether to throw errors when calling checkUpdate and downloadUpdate, defaults to not throwing errors, error information is obtained via lastError // With this enabled, you can use try catch statements to catch errors, and lastError will still be available // try { // await checkUpdate(); // } catch (e) { // console.error(e); // } // Requires v10.15.2+ throwError?: boolean; // Execute before checking for updates, return false to cancel the update check // Requires v10.12.0+ beforeCheckUpdate?: () => Promise; // Execute before downloading updates, return false to cancel the download, can be used with custom metaInfo for conditional control // Requires v10.12.0+ beforeDownloadUpdate?: (info: UpdateInfo) => Promise; // Execute after downloading updates, return false to cancel further execution of the built-in strategy, can be used with custom metaInfo for conditional control // Requires v10.27.0+ afterDownloadUpdate?: (info: UpdateInfo) => Promise; // Execute when the native package expires, return false to cancel further execution of the built-in strategy, can be used with custom metaInfo for conditional control // Requires v10.28.2+ onPackageExpired?: (info: UpdateInfo) => Promise; } // Log event types type EventType = // Update failed, rollback occurred after restart | "rollback" // Error during update check | "errorChecking" // Checking for updates | "checking" // Downloading update | "downloading" // Update downloaded | "downloadSuccess" // Update failed | "errorUpdate" // Update successful | "markSuccess" // Downloading apk | "downloadingApk" // Storage permission rejected before downloading apk | "rejectStoragePermission" // Error obtaining storage permission before downloading apk | "errorStoragePermission" // Error during apk download and installation | "errorDownloadAndInstallApk"; // Log event data interface EventData { // Current hot update hash value, empty string if no hot update yet currentVersion: string; // Client version information cInfo: { rnu: string; // Current react-native-update version rn: string; // Current react-native version os: string; // Current operating system and version uuid: string; // User identifier }; // Client native version number packageVersion: string; // Compilation timestamp buildTime: number; // Error related information message?: string; // Rolled back version hash value rolledBackVersion?: string; // New version hash value for update failure newVersion?: string; // Other data [key: string]: any; } // Example usage: // const pushy = new Pushy({ // appKey: "YOUR_APP_KEY", // checkStrategy: "both", // updateStrategy: "alertUpdateAndIgnoreError", // logger: ({ type, data }) => { // console.log(`Pushy Event: ${type}`, data); // } // }); ``` -------------------------------- ### JavaScript API - getCurrentVersionInfo / currentVersionInfo Source: https://context7.com/reactnativecn/pushy-site/llms.txt Retrieves information about the currently installed hot update version, including its name, description, and metadata. For versions v10.31.2+, the `currentVersionInfo` property can be accessed directly. ```APIDOC ## JavaScript API - getCurrentVersionInfo / currentVersionInfo ### Description Retrieves information about the currently installed hot update version, including its name, description, and metadata. For versions v10.31.2+, the `currentVersionInfo` property can be accessed directly. ### Method `getCurrentVersionInfo(): VersionInfo | null` or `currentVersionInfo: VersionInfo | null` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { useUpdate } from "react-native-update"; const { currentVersionInfo, currentHash, packageVersion } = useUpdate(); console.log("Native Version:", packageVersion); console.log("Hot Update Hash:", currentHash || "N/A"); if (currentVersionInfo) { console.log("Hot Update Version Name:", currentVersionInfo.name); console.log("Update Description:", currentVersionInfo.description); console.log("Meta Info:", currentVersionInfo.metaInfo); } ``` ### Response #### Success Response (VersionInfo | null) - `name` (string): The name of the hot update version. - `description` (string): The description of the hot update. - `metaInfo` (object): Additional metadata associated with the hot update. - Returns `null` if no hot update information is available. #### Response Example ```json { "name": "1.0.1", "description": "Fixed login bug", "metaInfo": { "silent": true } } ``` ``` -------------------------------- ### Pushy CLI: Login and Create Application Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/getting-started.mdx Provides commands for logging into the Pushy service using email and password, and for creating new applications for iOS, Android, and Harmony platforms. It also covers selecting existing applications and explains the generated `update.json` file. ```bash $ pushy login email: <输入你的注册邮箱> password: <输入你的密码> ``` ```bash $ pushy createApp --platform ios App Name: <输入应用名字> ``` ```bash $ pushy createApp --platform android App Name: <输入应用名字> ``` ```bash $ pushy createApp --platform harmony App Name: <输入应用名字> ``` ```bash $ pushy selectApp --platform ios 1) 鱼多多(ios) 2) 招财旺(ios) Total 2 ios apps Enter appId: <输入应用前面的编号> ``` -------------------------------- ### Custom Update UI with useUpdate Hook Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/integration.mdx This example demonstrates how to use the `useUpdate` hook from 'react-native-update' to manage and display custom update interfaces. It includes checking for updates, downloading, and handling user prompts for restarting. ```javascript import { Text, View, TouchableOpacity } from 'react-native'; import { useUpdate } from "react-native-update"; import { Icon, PaperProvider, Snackbar, Banner } from "react-native-paper"; function App() { const { client, checkUpdate, downloadUpdate, switchVersionLater, switchVersion, updateInfo, packageVersion, currentHash, progress: { received, total } = {}, } = useUpdate(); const [showUpdateBanner, setShowUpdateBanner] = useState(false); const [showUpdateSnackbar, setShowUpdateSnackbar] = useState(false); const snackbarVisible = showUpdateSnackbar && updateInfo?.update; return ( 更新下载进度:{received} / {total} { checkUpdate(); setShowUpdateSnackbar(true); }} > 点击这里检查更新 {snackbarVisible && ( { setShowUpdateSnackbar(false); }} action={{ label: "更新", onPress: async () => { setShowUpdateSnackbar(false); if (await downloadUpdate()) { setShowUpdateBanner(true); } }, }} > 有新版本({updateInfo.name})可用,是否更新? )} { switchVersionLater(); setShowUpdateBanner(false); }, }, ]} icon={({ size }) => ( )} > 更新已完成,是否立即重启? ); } ``` -------------------------------- ### pushy packages Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Lists uploaded native packages. ```APIDOC ## pushy packages ### Description Lists all uploaded native packages. This operation can also be performed on the web management interface. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Command Line Arguments - **platform** (ios|android|harmony) - Optional - Filters packages by platform. ### Response #### Success Response - **packages** (array) - A list of package objects. - **packageId** (string) - The ID of the package. - **version** (string) - The version name of the package. - **platform** (string) - The platform of the package. #### Response Example ```json { "packages": [ { "packageId": "pkg789", "version": "1.0.0", "platform": "android" } ] } ``` ``` -------------------------------- ### Create New Application (pushy createApp) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Creates a new application within the hot update platform and binds it to the current project. This can also be done via the web interface. Requires platform, name, and download URL. ```bash pushy createApp ``` -------------------------------- ### pushy selectApp Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Binds an application to the current project. ```APIDOC ## pushy selectApp [appId] ### Description Binds an application to the current project. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Path Parameters - **appId** (string) - Required - The ID of the application to bind. #### Command Line Arguments - **platform** (ios|android|harmony) - Required - The platform of the application. ### Response #### Success Response - **message** (string) - A success message indicating the app was bound. #### Response Example ```json { "message": "Application bound to current project successfully." } ``` ``` -------------------------------- ### Check for Updates with useUpdate() Hook in React Native Source: https://context7.com/reactnativecn/pushy-site/llms.txt Manually triggers an update check and returns update information. It's recommended to use the `useUpdate()` hook to get `updateInfo` for decoupling check and update logic. This hook is essential for detecting new versions or expired native packages. ```javascript import { useUpdate } from "react-native-update"; import { useEffect } from "react"; import { View } from "react-native"; function App() { const { checkUpdate, updateInfo } = useUpdate(); useEffect(() => { // Check for updates when the component mounts checkUpdate(); }, []); useEffect(() => { // Handle update logic when updateInfo changes if (!updateInfo) return; if (updateInfo.expired) { // Example return value: { expired: true, downloadUrl: "https://..." } console.log("Native package has expired, download URL:", updateInfo.downloadUrl); } else if (updateInfo.upToDate) { // Example return value: { upToDate: true } console.log("Already on the latest version"); } else if (updateInfo.update) { // Example return value: // { // update: true, // name: "1.0.3-rc", // hash: "abc123...", // description: "Fixed several bugs", // metaInfo: '{"silent":true,"force":false}', // pdiffUrl: "https://...", // diffUrl: "https://..." // } console.log("New version found:", updateInfo.name); } }, [updateInfo]); return ; } ``` -------------------------------- ### pushy uploadApp Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Uploads an App file to the open platform. ```APIDOC ## pushy uploadApp [appFile] ### Description Uploads an App file to the open platform. Requires CLI version 1.24.0 or higher. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Path Parameters - **appFile** (string) - Required - The path to the App file to upload. ### Response #### Success Response - **packageId** (string) - The ID of the uploaded package. - **message** (string) - A success message. #### Response Example ```json { "packageId": "pkg789", "message": "App file uploaded successfully." } ``` ``` -------------------------------- ### pushy versions Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Lists available hot update versions. ```APIDOC ## pushy versions ### Description Paginates and lists available hot update versions. This operation can also be performed on the web management interface. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Command Line Arguments - **platform** (ios|android|harmony) - Optional - Filters versions by platform. ### Response #### Success Response - **versions** (array) - A list of version objects. - **versionId** (string) - The ID of the version. - **name** (string) - The name of the version. - **description** (string) - The description of the version. - **platform** (string) - The platform of the version. #### Response Example ```json { "versions": [ { "versionId": "ver123", "name": "1.0.0", "description": "Initial release", "platform": "android" } ] } ``` ``` -------------------------------- ### 手动链接 iOS 模块 (RN < 0.60, CocoaPods) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/getting-started.mdx 在 Podfile 中添加 Pushy 的本地路径,然后运行 pod install。 ```ruby pod 'react-native-update', path: '../node_modules/react-native-update' ``` -------------------------------- ### 手动链接 Android 模块 (RN < 0.60) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/getting-started.mdx 在 settings.gradle 中引入模块,并在 app/build.gradle 的 dependencies 中添加项目。最后,在 MainApplication.java 中导入并注册 UpdatePackage。 ```gradle include ':react-native-update' project(':react-native-update').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-update/android') ``` ```gradle implementation project(':react-native-update') ``` ```java import cn.reactnative.modules.update.UpdatePackage; // ... @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, // in order they will be executed. // packages.add(new MyReactNativePackage()); packages.add(new UpdatePackage()); // <-- Add this line return packages; } ``` -------------------------------- ### List Applications (pushy apps) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Lists all created applications associated with the current account on the hot update platform. This operation can also be performed via the web interface. Can filter by platform. ```bash pushy apps ``` -------------------------------- ### pushy uploadIpa Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Uploads an IPA file to the open platform. ```APIDOC ## pushy uploadIpa [ipaFile] ### Description Uploads an IPA file to the open platform. Requires CLI version 1.24.0 or higher. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Path Parameters - **ipaFile** (string) - Required - The path to the IPA file to upload. ### Response #### Success Response - **packageId** (string) - The ID of the uploaded package. - **message** (string) - A success message. #### Response Example ```json { "packageId": "pkg789", "message": "IPA file uploaded successfully." } ``` ``` -------------------------------- ### List Available Versions (pushy versions) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Lists available hot update versions for an application, paginated. This operation can also be performed via the web interface. Can filter by platform. ```bash pushy versions ``` -------------------------------- ### 手动链接 iOS 模块 (RN < 0.60, 无 CocoaPods) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/getting-started.mdx 在 Xcode 中手动添加 RCTPushy.xcodeproj,链接库文件,并配置 Header Search Path 和 Run Script Phase。 ```bash #!/bin/bash set -x DEST="../node_modules/react-native-update/ios/" date +%s > "$DEST/pushy_build_time.txt" ``` -------------------------------- ### Android APK CPU 架构分离编译 Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/bestpractice.md 通过修改 `android/app/build.gradle` 文件,启用单独的 CPU 架构编译,可以减小 APK 文件的大小。此配置会生成多个针对不同 CPU 架构的 APK 文件,从而优化分发和上传到热更新服务的大小。 ```gradle splits { abi { reset() enable true // 启用单独的 cpu 架构编译 universalApk false // If true, also generate a universal APK } } ``` -------------------------------- ### pushy uploadApk Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Uploads an APK file to the open platform. ```APIDOC ## pushy uploadApk [apkFile] ### Description Uploads an APK file to the open platform. Requires CLI version 1.24.0 or higher. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Path Parameters - **apkFile** (string) - Required - The path to the APK file to upload. ### Response #### Success Response - **packageId** (string) - The ID of the uploaded package. - **message** (string) - A success message. #### Response Example ```json { "packageId": "pkg789", "message": "APK file uploaded successfully." } ``` ``` -------------------------------- ### Add Pushy Dependencies to Harmony CMakeLists.txt Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/getting-started.mdx This snippet shows how to add the Pushy library as a dependency in the CMakeLists.txt file for Harmony OS projects. It ensures that the necessary Pushy modules are included in the build process. ```cpp add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy) target_link_libraries(rnoh_app PUBLIC rnoh_pushy) ``` -------------------------------- ### pushy login Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Logs into the hot update open platform. ```APIDOC ## pushy login [email][pwd] ### Description Logs into the hot update open platform. You must log in before using subsequent commands. ### Method CLI Command ### Endpoint N/A (Local command) ### Parameters #### Path Parameters - **email** (string) - Required - The email address for login. - **pwd** (string) - Required - The password for login. ### Response #### Success Response - **message** (string) - A success message indicating login. #### Response Example ```json { "message": "Successfully logged in." } ``` ``` -------------------------------- ### List Uploaded Native Packages (pushy packages) Source: https://github.com/reactnativecn/pushy-site/blob/master/site/pages/docs/cli.md Lists all uploaded native packages (e.g., IPA, APK) associated with an application on the hot update platform. This operation can also be performed via the web interface. Can filter by platform. ```bash pushy packages ```