### Example CLI Commands for Setup Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExampleApp/README.md Demonstrates various ways to run the setup script, including specifying a React Native version, skipping pod installation, and forcing recreation of an existing app directory. ```bash # Create an example app for RN 0.83.1 npm run setup-example-app -- -v 0.83.1 # Create without pod install (useful on non-macOS or CI) npm run setup-example-app -- -v 0.84.0 --skip-pod-install # Recreate an existing example app directory npm run setup-example-app -- -v 0.83.1 --force-recreate ``` -------------------------------- ### Run Setup Example App CLI Command Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExampleApp/README.md Execute the setup script to create a React Native example app. Specify the React Native version using the -v flag. ```bash npm run setup-example-app -- -v ``` -------------------------------- ### Run Setup Expo Example App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExpoExampleApp/README.md Execute the script to set up an Expo example app. Specify the Expo SDK major version using the --sdk flag. ```bash npm run setup-expo-example-app -- --sdk ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/Expo55/README.md Run this command in your project's root directory to install all necessary dependencies. ```bash npm install ``` -------------------------------- ### Install @bravemobile/react-native-code-push Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/README.md Install the library using npm. ```bash npm install @bravemobile/react-native-code-push ``` -------------------------------- ### Create Expo SDK 55 App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExpoExampleApp/README.md Example command to create an Expo example app using SDK version 55. ```bash # Create Expo SDK 55 app npm run setup-expo-example-app -- --sdk 55 ``` -------------------------------- ### Configure Mixed Install Modes for Updates Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Install optional updates on the next restart and mandatory updates on the next resume. ```javascript // Download the update silently, and install optional updates // on the next restart, but install mandatory updates on the next resume. codePush.sync({ mandatoryInstallMode: codePush.InstallMode.ON_NEXT_RESUME }); ``` -------------------------------- ### Example: Display 'What's New' Dialog Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md This example shows how to use the promise returned by `codePush.getCurrentPackage()` to check if the current session is the first run of an update and if a description is available, then display a 'what's new?' modal. ```javascript codePush.getCurrentPackage() .then((update) => { // If the current app "session" represents the first time // this update has run, and it had a description provided // with it upon release, let's show it to the end user if (update.isFirstRun && update.description) { // Display a "what's new?" modal } }); ``` -------------------------------- ### Create Expo App in Custom Directory Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExpoExampleApp/README.md Example command to create an Expo example app using SDK version 54 and specify a custom working directory for the app. ```bash # Create in a custom directory npm run setup-expo-example-app -- --sdk 54 -w /tmp/examples ``` -------------------------------- ### Install CocoaPods Dependencies Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/README.md After initializing CodePush, install the necessary CocoaPods dependencies for iOS. ```bash cd ios && pod install && cd .. ``` -------------------------------- ### Install Plugin Locally in React Native Project Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md After cloning the repository and installing dependencies, use this command to install the plugin locally into your React Native project for manual testing. ```bash npm install local_path_to_your_clone_of_this_repo ``` -------------------------------- ### Create Expo SDK 55 Beta App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExpoExampleApp/README.md Example command to create a beta version of an Expo SDK 55 example app. The --beta flag adds a 'Beta' suffix to the app name. ```bash # Create Expo SDK 55 beta app npm run setup-expo-example-app -- --sdk 55 --beta ``` -------------------------------- ### Install CocoaPods Dependencies Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0803/README.md Installs CocoaPods dependencies for iOS projects. Run 'bundle install' once, then 'bundle exec pod install' after updating native dependencies. ```sh bundle install ``` ```sh bundle exec pod install ``` -------------------------------- ### Example: Prevent Restarts During Onboarding Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md This example demonstrates how to use `codePush.disallowRestart()` in `componentWillMount` and `codePush.allowRestart()` in `componentWillUnmount` to ensure no CodePush updates interrupt an onboarding process. ```javascript class OnboardingProcess extends Component { ... componentWillMount() { // Ensure that any CodePush updates which are // synchronized in the background can't trigger // a restart while this component is mounted. codePush.disallowRestart(); } componentWillUnmount() { // Reallow restarts, and optionally trigger // a restart if one was currently pending. codePush.allowRestart(); } ... } ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0840/README.md Starts the Metro JavaScript bundler for React Native development. Use npm or Yarn. ```sh npm start # OR using Yarn yarn start ``` -------------------------------- ### Quick Start: Initialize and Release an OTA Update Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md This sequence demonstrates the basic steps to set up CodePush for your project, create a release history, and then bundle and release an OTA update for a specific binary version and platform. ```bash npx code-push init # 2. Create a config file (see Configuration below) npx code-push create-history -b 1.0.0 -p ios npx code-push release -b 1.0.0 -v 1.0.1 -p ios ``` -------------------------------- ### Configure Silent Update Installation Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Download updates silently and install them on the next resume, provided a minimum background duration has passed. ```javascript // Download the update silently, but install it on // the next resume, as long as at least 5 minutes // has passed since the app was put into the background. codePush.sync({ installMode: codePush.InstallMode.ON_NEXT_RESUME, minimumBackgroundDuration: 60 * 5 }); ``` -------------------------------- ### Start the Expo Development Server Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/Expo55/README.md Launches the Expo development server, providing options to open the app on various platforms or simulators. ```bash npx expo start ``` -------------------------------- ### Bundle for Android with Custom Entry File Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md Example of bundling code specifically for Android, using a custom entry file (`index.js`) instead of the default. ```bash npx code-push bundle -p android -e index.js ``` -------------------------------- ### Install CocoaPods Dependencies Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0773/README.md Installs dependencies for iOS projects using CocoaPods. Run 'bundle install' once to install the bundler, then 'bundle exec pod install' after updating native dependencies. ```sh bundle install bundle exec pod install ``` -------------------------------- ### Set up ESLint for Linting Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/Expo55/README.md Initiates ESLint setup for code linting within the Expo project. ```bash npx expo lint ``` -------------------------------- ### Handle Sync Status and Download Progress Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Prompt the user when an update is available and display a 'downloading' modal, updating its progress. This example also shows how to handle different sync statuses. ```javascript // Prompt the user when an update is available // and then display a "downloading" modal codePush.sync({ updateDialog: true }, (status) => { switch (status) { case codePush.SyncStatus.DOWNLOADING_PACKAGE: // Show "downloading" modal break; case codePush.SyncStatus.INSTALLING_UPDATE: // Hide "downloading" modal break; } }, ({ receivedBytes, totalBytes, }) => { /* Update download modal progress */ } ); ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0773/README.md Starts the Metro JavaScript bundler, which is essential for running React Native applications. Use either npm or Yarn. ```sh # Using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Display Update Prompt with Release Description Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Show an update prompt that includes the description of the CodePush release and install the update immediately. ```javascript // Displaying an update prompt which includes the // description associated with the CodePush release codePush.sync({ updateDialog: { appendReleaseDescription: true, descriptionPrefix: "\n\nChange log:\n" }, installMode: codePush.InstallMode.IMMEDIATE }); ``` -------------------------------- ### Release History JSON Structure Example Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md An example of the JSON structure for release history, keyed by app version. This format is used internally by CodePush to manage update information. ```json { "1.0.0": { "enabled": true, "mandatory": false, "downloadUrl": "", "packageHash": "" }, "1.0.1": { "enabled": true, "mandatory": false, "downloadUrl": "https://storage.example.com/bundles/ios/staging/a1b2c3...", "packageHash": "a1b2c3...", "rollout": 100 }, "1.0.2": { "enabled": true, "mandatory": true, "downloadUrl": "https://storage.example.com/bundles/ios/staging/d4e5f6...", "packageHash": "d4e5f6..." } } ``` -------------------------------- ### LocalPackage Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Represents a downloaded update that is either already running or has been installed and is pending an app restart. It contains details about the update and methods to manage its installation. ```APIDOC ## LocalPackage ### Description Contains details about an update that has been downloaded locally or already installed. You can get a reference to an instance of this object either by calling the module-level `getUpdateMetadata` method, or as the value of the promise returned by the `RemotePackage.download` method. ### Properties - __appVersion__ (String) - The app binary version that this update is dependent on. This is the value that was specified via the `appStoreVersion` parameter when calling the CLI's `release` command. - __deploymentKey__ (String) - The deployment key that was used to originally download this update. - __description__ (String) - The description of the update. This is the same value that you specified in the CLI when you released the update. - __failedInstall__ (Boolean) - Indicates whether this update has been previously installed but was rolled back. The `sync` method will automatically ignore updates which have previously failed, so you only need to worry about this property if using `checkForUpdate`. - __isFirstRun__ (Boolean) - Indicates whether this is the first time the update has been run after being installed. This is useful for determining whether you would like to show a "What's New?" UI to the end user after installing an update. - __isMandatory__ (Boolean) - Indicates whether the update is considered mandatory. This is the value that was specified in the CLI when the update was released. - __isPending__ (Boolean) - Indicates whether this update is in a "pending" state. When `true`, that means the update has been downloaded and installed, but the app restart needed to apply it hasn't occurred yet, and therefore, it's changes aren't currently visible to the end-user. - __label__ (String) - The internal label automatically given to the update by the CodePush server, such as `v5`. This value uniquely identifies the update within it's deployment. - __packageHash__ (String) - The SHA hash value of the update. - __packageSize__ (Number) - The size of the code contained within the update, in bytes. ### Methods - __install(installMode: codePush.InstallMode = codePush.InstallMode.ON_NEXT_RESTART, minimumBackgroundDuration = 0): Promise__ - Installs the update by saving it to the location on disk where the runtime expects to find the latest version of the app. The `installMode` parameter controls when the changes are actually presented to the end user. The default value is to wait until the next app restart to display the changes, but you can refer to the [`InstallMode`](#installmode) enum reference for a description of the available options and what they do. If the `installMode` parameter is set to `InstallMode.ON_NEXT_RESUME`, then the `minimumBackgroundDuration` parameter allows you to control how long the app must have been in the background before forcing the install after it is resumed. ``` -------------------------------- ### iOS Prebuild Behavior by React Native Version Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExampleApp/README.md Illustrates the different commands used for `pod install` based on the React Native version, including specific flags for older versions and the default behavior for newer versions. ```bash # RN < 0.81.0: bundle install && cd ios && bundle exec pod install # RN 0.81.x to 0.83.x: bundle install && cd ios && RCT_USE_RN_DEP=1 RCT_USE_PREBUILT_RNCORE=1 bundle exec pod install # RN >= 0.84.0: falls back to the default command ``` -------------------------------- ### E2E Testing Directory Structure Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/e2e/README.md Overview of the files and directories used in the end-to-end testing setup. ```tree e2e/ ├── run.ts # Main orchestration script ├── config.ts # Paths, ports, host configuration ├── tsconfig.json ├── mock-server/ │ └── server.ts # Express static file server (port 18081) ├── templates/ │ └── code-push.config.local.ts # Filesystem-based CodePush config ├── helpers/ │ ├── prepare-config.ts # Patches App.tsx (host + temporary E2E buttons), copies config │ ├── prepare-bundle.ts # Runs code-push CLI to create bundles │ └── build-app.ts # Builds iOS/Android in Release mode ├── flows/ # Phase 1: basic flows ├── flows-rollback/ # Phase 2: rollback to binary ├── flows-partial-rollback/ # Phase 3: partial rollback (v1.0.2 → v1.0.1) ├── flows-optional/ # Phase 4: optional install mode verification └── scripts/ └── sleep.js # Maestro runScript helper for deterministic waits ``` -------------------------------- ### Run E2E Tests for Expo App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExpoExampleApp/README.md Command to execute end-to-end tests for a previously set up Expo example app. Specify the app name, framework, and platform. ```bash npm run e2e -- --app Expo55 --framework expo --platform ios ``` -------------------------------- ### Remove and Install CodePush Packages Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/README.md Use these commands to migrate from react-native-code-push to @bravemobile/react-native-code-push. ```bash npm remove react-native-code-push npm install @bravemobile/react-native-code-push ``` -------------------------------- ### Configure CodePush using CodePushBuilder Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-android.md Set up a CodePush instance using the CodePushBuilder, allowing configuration of deployment key, debug mode, and server URL. This example demonstrates setting these parameters programmatically within your MainActivity.java. ```java import com.microsoft.codepush.react.CodePushBuilder; import com.microsoft.codepush.react.ReactPackage; import com.facebook.react.ReactPackage; import com.facebook.react.ReactActivity; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import java.util.List; import java.util.Arrays; // ... inside your MainActivity class or similar @Override protected List getPackages() { return Arrays.asList( new MainReactPackage(), new CodePushBuilder("deployment-key-here", getApplicationContext()) .setIsDebugMode(BuildConfig.DEBUG) .setServerUrl("https://yourcodepush.server.com") .build() //return configured CodePush instance ); } ``` -------------------------------- ### codePush.getCurrentPackage Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Retrieves metadata about the currently installed CodePush package, such as its description and installation time. Returns null if the app is running the binary's JS bundle. ```APIDOC ## codePush.getCurrentPackage ### Description Retrieves the metadata about the currently installed CodePush package (e.g., description, installation time). This can be used for scenarios like displaying a "what's new?" dialog or checking for pending updates. *NOTE: This method is deprecated. Use `codePush.getUpdateMetadata` instead.* ### Method `Promise getCurrentPackage()` ### Parameters None ### Request Example ```javascript codePush.getCurrentPackage() .then((update) => { if (update && update.isFirstRun && update.description) { // Display a "what's new?" modal } }); ``` ### Response #### Success Response - **LocalPackage | null**: A `LocalPackage` instance containing metadata for the currently running CodePush update, or `null` if the app is running the binary's JS bundle. ``` -------------------------------- ### Install React Native CLI Globally Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md Ensure the React Native command-line interface is installed globally. This is required for running React Native specific commands and tests. ```bash npm install -g react-native ``` -------------------------------- ### Run Expo E2E Matrix Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/e2e/README.md Executes E2E tests for Expo example apps, discovering apps, creating them, and running tests across platforms. Continues on failure and provides a summary. ```bash bash scripts/e2e/run-expo-matrix.sh ``` ```bash bash scripts/e2e/run-expo-matrix.sh --only android ``` ```bash bash scripts/e2e/run-expo-matrix.sh --force-recreate --only ios ``` -------------------------------- ### getCurrentPackage Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Retrieves the metadata about the currently installed update (like description, installation time, size). NOTE: As of `v1.10.3-beta` of the CodePush module, this method is deprecated in favor of `getUpdateMetadata`. ```APIDOC ## getCurrentPackage (Deprecated) ### Description Retrieves the metadata about the currently installed update (like description, installation time, size). *NOTE: As of `v1.10.3-beta` of the CodePush module, this method is deprecated in favor of [`getUpdateMetadata`](#codepushgetupdatemetadata)*. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters None explicitly documented for direct invocation. ### Request Example ```javascript import codePush from 'react-native-code-push'; codePush.getCurrentPackage().then(packageInfo => { if (packageInfo) { console.log('Current package info:', packageInfo); } }); ``` ### Response Returns a Promise that resolves to an object containing metadata about the currently installed update. ``` -------------------------------- ### sync Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Allows checking for an update, downloading it and installing it, all with a single call. Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating CodePush into their apps. ```APIDOC ## sync ### Description Allows checking for an update, downloading it and installing it, all with a single call. Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating CodePush into their apps. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters This method can accept an optional `syncOptions` object to customize its behavior. Refer to the CodePush documentation for detailed options. ### Request Example ```javascript import codePush from 'react-native-code-push'; codePush.sync(); // Basic sync // With options codePush.sync({ installMode: codePush.InstallMode.IMMEDIATE, updateDialog: true }); ``` ### Response Returns a Promise that resolves to a status code indicating the result of the sync operation. ``` -------------------------------- ### Run React Native CLI E2E Matrix Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/e2e/README.md Executes E2E tests for React Native CLI example apps, creating apps, discovering versions, and running tests across platforms. Continues on failure and provides a summary. ```bash bash scripts/e2e/run-rn-cli-matrix.sh ``` ```bash bash scripts/e2e/run-rn-cli-matrix.sh --only android ``` ```bash bash scripts/e2e/run-rn-cli-matrix.sh --only-setup ``` ```bash bash scripts/e2e/run-rn-cli-matrix.sh --maestro-only ``` ```bash bash scripts/e2e/run-rn-cli-matrix.sh --legacy-arch-max-version 81 ``` ```bash bash scripts/e2e/run-rn-cli-matrix.sh --skip-setup --only ios ``` -------------------------------- ### Get Current CodePush Package Metadata Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Use `codePush.getCurrentPackage()` to retrieve metadata about the currently installed CodePush update, such as its description and installation time. This method is deprecated in favor of `codePush.getUpdateMetadata`. ```javascript codePush.getCurrentPackage(): Promise; ``` -------------------------------- ### Reset Project to a Fresh State Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/Expo55/README.md Moves the starter code to 'app-example' and creates a new blank 'app' directory for development. ```bash npm run reset-project ``` -------------------------------- ### getUpdateMetadata Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Retrieves the metadata for an installed update (like description, mandatory). This is the recommended method to get update metadata, replacing `getCurrentPackage`. ```APIDOC ## getUpdateMetadata ### Description Retrieves the metadata for an installed update (like description, mandatory). This is the recommended method to get update metadata, replacing `getCurrentPackage`. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters None explicitly documented for direct invocation. ### Request Example ```javascript import codePush from 'react-native-code-push'; codePush.getUpdateMetadata().then(updateMetadata => { if (updateMetadata) { console.log('Update metadata:', updateMetadata); } }); ``` ### Response Returns a Promise that resolves to an object containing metadata for the installed update. ``` -------------------------------- ### Get Update Metadata Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Retrieves metadata for an installed or pending CodePush update. Useful for displaying update information or checking for pending updates. ```javascript codePush.getUpdateMetadata(updateState: UpdateState = UpdateState.RUNNING): Promise; ``` ```javascript // Check if there is currently a CodePush update running, and if // so, register it with the HockeyApp SDK (https://github.com/slowpath/react-native-hockeyapp) // so that crash reports will correctly display the JS bundle version the user was running. codePush.getUpdateMetadata().then((update) => { if (update) { hockeyApp.addMetadata({ CodePushRelease: update.label }); } }); ``` ```javascript // Check to see if there is still an update pending. codePush.getUpdateMetadata(UpdateState.PENDING).then((update) => { if (update) { // There's a pending update, do we want to force a restart? } }); ``` -------------------------------- ### Initialize CodePush Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExampleApp/README.md Runs the CodePush initialization command to inject configuration into native projects. ```bash npx code-push init ``` -------------------------------- ### Prepare Release Bundle Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/e2e/README.md Creates release history and bundles a new version of the app using the CodePush CLI. This is a prerequisite for testing update flows. ```bash npx code-push release ``` -------------------------------- ### Show Release History Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md Display the release history for a given binary version. This command helps in reviewing past updates and their configurations. ```bash npx code-push show-history [options] ``` ```bash npx code-push show-history -b 1.0.0 -p ios ``` -------------------------------- ### Run All Unit Tests on iOS and Restart Emulators Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md Execute all unit tests on iOS and ensure emulators are restarted (killing existing ones if necessary) by setting the CLEAN environment variable to true. ```bash CLEAN=true npm run test:ios ``` -------------------------------- ### notifyAppReady Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Notifies the CodePush runtime that an installed update is considered successful. If you are manually checking for and installing updates, this method MUST be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts. ```APIDOC ## notifyAppReady ### Description Notifies the CodePush runtime that an installed update is considered successful. If you are manually checking for and installing updates (i.e. not using the [sync](#codepushsync) method to handle it all for you), then this method **MUST** be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters None explicitly documented for direct invocation. ### Request Example ```javascript import codePush from 'react-native-code-push'; // Assuming an update has been installed and the app has restarted codePush.notifyAppReady(); ``` ### Response None explicitly documented. ``` -------------------------------- ### Run iOS App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0840/README.md Builds and runs the iOS application. Use npm or Yarn. ```sh npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Run Android App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0840/README.md Builds and runs the Android application. Use npm or Yarn. ```sh npm run android # OR using Yarn yarn android ``` -------------------------------- ### codePush.notifyAppReady Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Notifies the CodePush runtime that a freshly installed update should be considered successful, preventing an automatic client-side rollback. ```APIDOC ## codePush.notifyAppReady ### Description Notifies the CodePush runtime that a freshly installed update should be considered successful, and therefore, an automatic client-side rollback isn't necessary. It is mandatory to call this function somewhere in the code of the updated bundle. Otherwise, when the app next restarts, the CodePush runtime will assume that the installed update has failed and roll back to the previous version. *NOTE: This method is also aliased as `notifyApplicationReady` (for backwards compatibility).* ### Method ```javascript codePush.notifyAppReady(): Promise; ``` ### Response - **Promise** - A Promise that resolves when the notification is complete. ### Request Example ```javascript // Call this after your app has successfully loaded the new update codePush.notifyAppReady(); ``` ``` -------------------------------- ### Get Current Platform Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExampleApp/templates/App.tsx.txt A utility function to determine the current operating system platform (iOS or Android). Throws an error for unsupported platforms. ```typescript function getPlatform() { switch (Platform.OS) { case 'ios': return 'ios'; case 'android': return 'android'; default: throw new Error('Unsupported platform'); } } ``` -------------------------------- ### codePush.getUpdateMetadata Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Retrieves the metadata for an installed CodePush update based on the specified update state. This is useful for displaying update information or checking for pending updates. ```APIDOC ## codePush.getUpdateMetadata ### Description Retrieves the metadata for an installed update (for example description, mandatory) whose state matches the specified `updateState` parameter. This can be useful for scenarios such as displaying a "what's new?" dialog after an update has been applied or checking whether there is a pending update that is waiting to be applied via a resume or restart. ### Method ```javascript codePush.getUpdateMetadata(updateState: UpdateState = UpdateState.RUNNING): Promise; ``` ### Parameters #### Query Parameters - **updateState** (UpdateState) - Optional - The state of the update to retrieve metadata for. Defaults to `UpdateState.RUNNING`. ### Response - **Promise** - A Promise that resolves to a `LocalPackage` instance representing the update metadata, or `null` if no update with the specified state exists. ### Request Example ```javascript // Check if there is currently a CodePush update running codePush.getUpdateMetadata().then((update) => { if (update) { console.log('Running update label:', update.label); } }); // Check to see if there is still an update pending. codePush.getUpdateMetadata(UpdateState.PENDING).then((update) => { if (update) { console.log('Pending update found.'); } }); ``` ``` -------------------------------- ### checkForUpdate Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Asks the CodePush service whether the configured app deployment has an update available. This method allows you to check for updates without automatically downloading or installing them. ```APIDOC ## checkForUpdate ### Description Asks the CodePush service whether the configured app deployment has an update available. This method allows you to check for updates without automatically downloading or installing them. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters None explicitly documented for direct invocation. ### Request Example ```javascript import codePush from 'react-native-code-push'; codePush.checkForUpdate().then(updateInfo => { if (updateInfo) { console.log('An update is available:', updateInfo); } else { console.log('No update available.'); } }); ``` ### Response Returns a Promise that resolves to an update package information object if an update is available, or `null` otherwise. ``` -------------------------------- ### Run Expo Prebuild Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/README.md After updating the Expo configuration, run 'npx expo prebuild' to apply the changes to your native project files. ```bash npx expo prebuild ``` -------------------------------- ### Notify App Ready Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Notifies the CodePush runtime that a freshly installed update is successful, preventing automatic rollback. Must be called in the updated bundle's code. ```javascript codePush.notifyAppReady(): Promise; ``` -------------------------------- ### Create CodePush Release History (CLI) Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/README.md Creates a new release history entry for a specific binary app version. Use this command when releasing a new binary app to the store to ensure the library recognizes it as the latest version. ```bash npx code-push create-history --binary-version 1.0.0 --platform ios --identifier staging ``` -------------------------------- ### Silent Update on App Start Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Implements a fully silent update strategy where the app automatically downloads and applies updates on the next restart without user interruption. ```javascript // Fully silent update which keeps the app in // sync with the server, without ever // interrupting the end user class MyApp extends Component<{}> {} MyApp = codePush(MyApp); export default MyApp; ``` -------------------------------- ### Reuse Existing Bundle for Release Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md Releases an OTA update (binary 1.0.0, app 1.0.2) by skipping the bundling step and calculating the hash from an existing bundle. This is useful for re-releasing without code changes. ```bash npx code-push release -b 1.0.0 -v 1.0.2 --skip-bundle true --hash-calc true ``` -------------------------------- ### Temporarily Disallow CodePush Restarts Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Use `codePush.disallowRestart()` to prevent programmatic restarts caused by immediate or resume-based installations, or direct calls to `restartApp`. Restarts are queued until `codePush.allowRestart()` is called. ```javascript codePush.disallowRestart(): void; ``` -------------------------------- ### Typical CodePush Workflow Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md A sequence of commands representing a common workflow for setting up and managing CodePush releases, from initialization to ongoing updates. ```bash 1. npx code-push init # One-time native setup 2. Create code-push.config.ts # One-time config 3. npx code-push create-history # Once per binary version 4. npx code-push release # Each OTA update 5. npx code-push update-history # Adjust rollout/flags as needed 6. npx code-push show-history # Check release history as needed ``` -------------------------------- ### Build and Run iOS App Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/Examples/RN0773/README.md Builds and runs the React Native application on an iOS simulator or device. Ensure Metro is running in a separate terminal and CocoaPods dependencies are installed. ```sh # Using npm npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Run All Unit Tests on Android and iOS Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md Execute the default test task to run all unit tests for both Android and iOS platforms. This is the primary command for comprehensive testing. ```bash npm run test ``` -------------------------------- ### Run All Unit Tests Without Building Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md Execute all unit tests on Android and iOS without rebuilding the app by using the ':fast' suffix. This speeds up the testing process. ```bash npm run test:fast ``` -------------------------------- ### disallowRestart Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Temporarily disallows any programmatic restarts to occur as a result of a CodePush update being installed. This is an advanced API, and is useful when a component within your app needs to ensure that no end-user interruptions can occur during its lifetime. ```APIDOC ## disallowRestart ### Description Temporarily disallows any programmatic restarts to occur as a result of a CodePush update being installed. This is an advanced API, and is useful when a component within your app (for example an onboarding process) needs to ensure that no end-user interruptions can occur during its lifetime. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters None explicitly documented for direct invocation. ### Request Example ```javascript import codePush from 'react-native-code-push'; codePush.disallowRestart(); ``` ### Response None explicitly documented. ``` -------------------------------- ### Create Release History Entry Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md Use this command to create a release history entry for a specific binary version. It is intended to be run once per binary version shipped to the app store. ```bash npx code-push create-history [options] ``` ```bash npx code-push create-history -b 1.0.0 -p ios -i production ``` -------------------------------- ### Release History Fetcher Configuration Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/setupExampleApp/templates/App.tsx.txt This function is used to fetch the release history for CodePush. It constructs a URL based on the app version, platform, and an identifier, then makes a GET request to retrieve the history. ```typescript async function releaseHistoryFetcher( updateRequest: UpdateCheckRequest, ): Promise { const jsonFileName = `${updateRequest.app_version}.json`; const releaseHistoryUrl = `${CODEPUSH_HOST}/histories/${getPlatform()}/${IDENTIFIER}/${jsonFileName}`; try { const response = await fetch(releaseHistoryUrl, { method: 'GET', headers: { Accept: 'application/json', 'Cache-Control': 'no-cache', }, }); if (!response.ok) { throw new Error(`Failed to fetch release history: ${response.status} ${response.statusText}`); } return (await response.json()) as ReleaseHistoryInterface; } catch (error) { console.error(error); throw error; } } ``` -------------------------------- ### Run All Unit Tests on iOS from NPM Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md Execute all unit tests on iOS while pulling the plugin directly from NPM by setting the NPM environment variable to true. This bypasses local testing. ```bash NPM=true npm run test:ios ``` -------------------------------- ### Initialize CodePush for Android Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/multi-deployment-testing-android.md Add this line to your MainActivity.java to initialize CodePush with your deployment key. Ensure BuildConfig.CODEPUSH_KEY is correctly set. ```java new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG) ``` -------------------------------- ### Show CodePush Release History (CLI) Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/README.md Displays the release history for a specified binary app version. This command is useful for reviewing past CodePush updates. ```bash npx code-push show-history --binary-version 1.0.0 --platform ios --identifier staging ``` -------------------------------- ### Run React Native CLI Legacy Arch E2E Matrix Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/scripts/e2e/README.md Executes E2E tests for React Native CLI apps with temporary legacy architecture setup for versions below 0.82. It handles temporary configuration changes for Android and iOS builds. ```bash bash scripts/e2e/run-rn-cli-legacy-arch-matrix.sh ``` ```bash bash scripts/e2e/run-rn-cli-legacy-arch-matrix.sh --only ios ``` ```bash bash scripts/e2e/run-rn-cli-legacy-arch-matrix.sh --skip-setup --only android ``` -------------------------------- ### allowRestart Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-js.md Re-allows programmatic restarts to occur as a result of an update being installed. It can also immediately restart the app if a pending update had attempted to restart the app while restarts were disallowed. This is an advanced API and is only necessary if your app explicitly disallowed restarts via the `disallowRestart` method. ```APIDOC ## allowRestart ### Description Re-allows programmatic restarts to occur as a result of an update being installed, and optionally, immediately restarts the app if a pending update had attempted to restart the app while restarts were disallowed. This is an advanced API and is only necessary if your app explicitly disallowed restarts via the `disallowRestart` method. ### Method N/A (JavaScript Method) ### Endpoint N/A (JavaScript Method) ### Parameters None explicitly documented for direct invocation. ### Request Example ```javascript import codePush from 'react-native-code-push'; codePush.allowRestart(); ``` ### Response None explicitly documented. ``` -------------------------------- ### Bundle Code for OTA Update Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/cli/README.md This command bundles your JavaScript code and compiles it with Hermes, preparing it for an OTA update. You can specify the platform, entry file, and output directory. ```bash npx code-push bundle [options] ``` -------------------------------- ### CodePush Class Methods Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/docs/api-ios.md Provides static methods for retrieving the appropriate JavaScript bundle URL for your React Native application. These methods handle different scenarios, including initial app installs, CodePush updates, and app store updates, ensuring users always receive the correct bundle. ```APIDOC ## CodePush Class Methods ### Description Contains static methods for retrieving the `NSURL` that represents the most recent JavaScript bundle file, and can be passed to the `RCTRootView`'s `initWithBundleURL` method when bootstrapping your app in the `AppDelegate.m` file. The `CodePush` class' methods can be thought of as composite resolvers which always load the appropriate bundle, in order to accommodate the following scenarios: 1. When an end-user installs your app from the store (like `1.0.0`), they will get the JS bundle that is contained within the binary. This is the behavior you would get without using CodePush, but we make sure it doesn't break :) 2. As soon as you begin releasing CodePush updates, your end-users will get the JS bundle that represents the latest release for the configured deployment. This is the behavior that allows you to iterate beyond what you shipped to the store. 3. As soon as you release an update to the app store (like `1.1.0`), and your end-users update it, they will once again get the JS bundle that is contained within the binary. This behavior ensures that CodePush updates that targetted a previous binary version aren't used (since we don't know if they would work), and your end-users always have a working version of your app. 4. Repeat #2 and #3 as the CodePush releases and app store releases continue on into infinity (and beyond?) Because of this behavior, you can safely deploy updates to both the app store(s) and CodePush as necesary, and rest assured that your end-users will always get the most recent version. ### Methods - **bundleURL** - Returns: `NSURL` - The most recent JS bundle `NSURL`. Assumes the JS bundle is named `main.jsbundle`. - **bundleURLForResource:** (NSString *)resourceName - Returns: `NSURL` - The most recent JS bundle `NSURL`. Allows customizing the JS bundle name. Assumes the JS bundle's extension is `*.jsbundle`. - **bundleURLForResource:** (NSString *)resourceName withExtension: (NSString *)resourceExtension - Returns: `NSURL` - The most recent JS bundle `NSURL`. Allows customizing the JS bundle name and extension. - **overrideAppVersion:** (NSString *)appVersionOverride - Description: Sets the version of the application's binary interface. Defaults to `CFBundleShortVersionString` from `Info.plist`. Should be called once before the bundle URL is loaded. - **setDeploymentKey:** (NSString *)deploymentKey - Description: Sets the deployment key for querying updates. This is a dynamic alternative to setting the key in `Info.plist` or in JS. ``` -------------------------------- ### Run Core Unit Tests on Android from NPM Source: https://github.com/soomgo-mobile/react-native-code-push/blob/master/CONTRIBUTING.md Execute only the core unit tests on Android and pull the plugin from NPM by setting both CORE and NPM environment variables to true. This combines focused testing with NPM sourcing. ```bash NPM=true CORE=true npm run test:android ```