Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
[![appcenterbanner](https://user-images.githubusercontent.com/31293287/32969262-3cc5d48a-cb99-11e7-91bf-fa57c67a371c.png)](http://microsoft.github.io/code-push/)

#### [Sign up With App Center](https://appcenter.ms/signup?utm_source=CodePush&utm_medium=Azure) to use CodePush

# React Native Module for CodePush
> [!WARNING]
> React Native CodePush won't support new Architecture. In order to use this plugin on React Native versions starting from 0.76 you will need to [opt out](https://reactnative.dev/blog/2024/10/23/the-new-architecture-is-here#opt-out) from new architecture.
>
*Note: This README is only relevant to the latest version of our plugin. If you are using an older version, please switch to the relevant tag on [our GitHub repo](https://github.com/microsoft/react-native-code-push) to view the docs for that particular version.*

![Switching tags](https://user-images.githubusercontent.com/42337914/57237511-0835de80-7030-11e9-88fa-64eb200478d0.png)

This plugin provides client-side integration for the [CodePush service](https://microsoft.github.io/code-push/), allowing you to easily add a dynamic update experience to your React Native app(s).

Expand Down Expand Up @@ -53,36 +45,16 @@ In order to ensure that your end users always have a functioning version of your

- iOS (7+)
- Android (4.1+) on TLS 1.2 compatible devices
- Windows (UWP)
- Windows (UWP) - Not Tested. We recommend to use [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push)

We try our best to maintain backwards compatibility of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the CodePush plugin in order to support the exact version of React Native you are using. The following table outlines which CodePush plugin versions officially support the respective React Native versions:

| React Native version(s) | Supporting CodePush version(s) |
|-------------------------|-------------------------------------------------------|
| <0.14 | **Unsupported** |
| v0.14 | v1.3 *(introduced Android support)* |
| v0.15-v0.18 | v1.4-v1.6 *(introduced iOS asset support)* |
| v0.19-v0.28 | v1.7-v1.17 *(introduced Android asset support)* |
| v0.29-v0.30 | v1.13-v1.17 *(RN refactored native hosting code)* |
| v0.31-v0.33 | v1.14.6-v1.17 *(RN refactored native hosting code)* |
| v0.34-v0.35 | v1.15-v1.17 *(RN refactored native hosting code)* |
| v0.36-v0.39 | v1.16-v1.17 *(RN refactored resume handler)* |
| v0.40-v0.42 | v1.17 *(RN refactored iOS header files)* |
| v0.43-v0.44 | v2.0+ *(RN refactored uimanager dependencies)* |
| v0.45 | v3.0+ *(RN refactored instance manager code)* |
| v0.46 | v4.0+ *(RN refactored js bundle loader code)* |
| v0.46-v0.53 | v5.1+ *(RN removed unused registration of JS modules)*|
| v0.54-v0.55 | v5.3+ *(Android Gradle Plugin 3.x integration)* |
| v0.56-v0.58 | v5.4+ *(RN upgraded versions for Android tools)* |
| v0.59 | v5.6+ *(RN refactored js bundle loader code)* |
| v0.60-v0.61 | v6.0+ *(RN migrated to Autolinking)* |
| v0.62-v0.64 | v6.2+ *(RN removed LiveReload)* |
| v0.65-v0.70 | v7.0+ *(RN updated iPhone-target-version)* |
| v0.71 | v8.0+ *(RN moved to react-native-gradle-plugin)* |

*NOTE: `react-native-code-push` versions lower than **[v5.7.0](https://github.com/microsoft/react-native-code-push/releases/tag/v5.7.0)** will stop working in the near future. You can find more information in our [documentation](https://github.com/microsoft/code-push/blob/master/migration-notice.md).*

We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is.
| React Native version(s) | Supporting CodePush version(s) |
|-------------------------|------------------------------------------------------------------------------------------------------|
| <v0.76 | **Consider [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push)** |
| v0.76 | v10.0+ *(Available for Old/New Architecture)* |



### Supported Components

Expand Down Expand Up @@ -117,7 +89,7 @@ As new core components are released, which support referencing assets, we'll upd
Once you've followed the general-purpose ["getting started"](https://docs.microsoft.com/en-us/appcenter/distribution/codepush/index) instructions for setting up your CodePush account, you can start CodePush-ifying your React Native app by running the following command from within your app's root directory:

```shell
npm install --save react-native-code-push
yarn add @code-push-next/react-native-code-push
```

As with all other React Native plugins, the integration experience is different for iOS and Android, so perform the following setup steps depending on which platform(s) you are targeting. Note, if you are targeting both platforms it is recommended to create separate CodePush applications for each platform.
Expand Down
8 changes: 3 additions & 5 deletions docs/api-android.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
### Java API Reference (Android)

### API for React Native 0.60 version and above
### Resource Configuration

Since `autolinking` uses `react-native.config.js` to link plugins, constructors are specified in that file. But you can override custom variables to manage the CodePush plugin by placing these values in string resources.

Expand All @@ -16,10 +14,10 @@ Since `autolinking` uses `react-native.config.js` to link plugins, constructors
<string moduleConfig="true" name="CodePushServerUrl">https://yourcodepush.server.com</string>
```

### API for React Native lower than 0.60

The Java API is made available by importing the `com.microsoft.codepush.react.CodePush` class into your `MainActivity.java` file, and consists of a single public class named `CodePush`.

### Java API Reference (Android)

#### CodePush

Constructs the CodePush client runtime and represents the `ReactPackage` instance that you add to you app's list of packages.
Expand Down
95 changes: 1 addition & 94 deletions docs/multi-deployment-testing-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/

To set this up, perform the following steps:

**For React Native >= v0.60**
**For React Native >= v0.76**

1. Open the project's app level `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)

Expand Down Expand Up @@ -51,98 +51,5 @@ To set this up, perform the following steps:

*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*

**For React Native v0.29 - v0.59**

1. Open up your `MainApplication.java` file and make the following changes:

```java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
...
new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
...
);
}
```

2. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)

3. Find the `android { buildTypes {} }` section and define `buildConfigField` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively. If you prefer, you can define the key literals in your `gradle.properties` file, and then reference them here. Either way will work, and it's just a matter of personal preference.

```groovy
android {
...
buildTypes {
debug {
...
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
buildConfigField "String", "CODEPUSH_KEY", '""'
...
}

releaseStaging {
...
buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
// Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
// Add the following line if not already there
matchingFallbacks = ['release']
...
}

release {
...
buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
...
}
}
...
}
```

*NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*

4. Pass the deployment key to the `CodePush` constructor via the build config you defined, as opposed to a string literal.

**For React Native v0.19 - v0.28**

Open up your `MainActivity.java` file and make the following changes:

```java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
...
new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG), // Add/change this line.
...
);
}
```

*Note: If you gave your build setting a different name in your Gradle file, simply make sure to reflect that in your Java code.*

And that's it! Now when you run or build your app, your debug builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.

*NOTE: By default, the `react-native run-android` command builds and deploys the debug version of your app, so if you want to test out a release/production build, simply run `react-native run-android --variant release. Refer to the [React Native docs](http://facebook.github.io/react-native/docs/signed-apk-android.html#conten) for details about how to configure and create release builds for your Android apps.*

If you want to be able to install both debug and release builds simultaneously on the same device (highly recommended!), then you need to ensure that your debug build has a unique identity and icon from your release build. Otherwise, neither the OS nor you will be able to differentiate between the two. You can achieve this by performing the following steps:

1. In your `build.gradle` file, specify the [`applicationIdSuffix`](http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:applicationIdSuffix) field for your debug build type, which gives your debug build a unique identity for the OS (like `com.foo` vs. `com.foo.debug`).

```groovy
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
```

2. Create the `app/src/debug/res` directory structure in your app, which allows overriding resources (like strings, icons, layouts) for your debug builds

3. Create a `values` directory underneath the debug res directory created in #2, and copy the existing `strings.xml` file from the `app/src/main/res/values` directory

4. Open up the new debug `strings.xml` file and change the `<string name="app_name">` element's value to something else (like `foo-debug`). This ensures that your debug build now has a distinct display name, so that you can differentiate it from your release build.

5. Optionally, create "mirrored" directories in the `app/src/debug/res` directory for all of your app's icons that you want to change for your debug build. This part isn't technically critical, but it can make it easier to quickly spot your debug builds on a device if its icon is noticeable different.

And that's it! View [here](http://tools.android.com/tech-docs/new-build-system/resource-merging) for more details on how resource merging works in Android.
Loading