|
1 | | -### Java API Reference (Android) |
2 | | - |
3 | | -### API for React Native 0.60 version and above |
| 1 | +### Resource Configuration |
4 | 2 |
|
5 | 3 | 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. |
6 | 4 |
|
7 | | -* __Public Key__ - used for bundle verification in the Code Signing Feature. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature. |
8 | | - To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`. CodePush automatically gets this property and enables the Code Signing feature. For example: |
9 | | - ```xml |
10 | | - <string moduleConfig="true" name="CodePushPublicKey">your-public-key</string> |
11 | | - ``` |
| 5 | +- **Public Key** - used for bundle verification in the Code Signing Feature. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature. |
| 6 | + To set the public key, you should add the content of the public key to `strings.xml` with name `CodePushPublicKey`. CodePush automatically gets this property and enables the Code Signing feature. For example: |
12 | 7 |
|
13 | | -* __Server Url__ - used for specifying CodePush Server Url. |
14 | | - The Default value: "https://codepush.appcenter.ms/" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`. CodePush automatically gets this property and will use this path to send requests. For example: |
15 | | - ```xml |
16 | | - <string moduleConfig="true" name="CodePushServerUrl">https://yourcodepush.server.com</string> |
17 | | - ``` |
| 8 | + ```xml |
| 9 | + <string moduleConfig="true" name="CodePushPublicKey">your-public-key</string> |
| 10 | + ``` |
18 | 11 |
|
19 | | -### API for React Native lower than 0.60 |
| 12 | +- **Server Url** - used for specifying CodePush Server Url. |
| 13 | + The Default value: "<https://api.srcpush.com>" is overridden by adding your path to `strings.xml` with name `CodePushServerUrl`. CodePush automatically gets this property and will use this path to send requests. For example: |
| 14 | + |
| 15 | + ```xml |
| 16 | + <string moduleConfig="true" name="CodePushServerUrl">https://api.srcpush.com</string> |
| 17 | + ``` |
20 | 18 |
|
21 | 19 | 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`. |
22 | 20 |
|
| 21 | +### Java API Reference (Android) |
| 22 | + |
23 | 23 | #### CodePush |
24 | 24 |
|
25 | 25 | Constructs the CodePush client runtime and represents the `ReactPackage` instance that you add to you app's list of packages. |
26 | 26 |
|
27 | 27 | ##### Constructors |
28 | 28 |
|
29 | | -- __CodePush(String deploymentKey, Activity mainActivity)__ - Creates a new instance of the CodePush runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your React packages list inside the `MainActivity` class. This constructor puts the CodePush runtime into "release mode", so if you want to enable debugging behavior, use the following constructor instead. |
| 29 | +- **CodePush(String deploymentKey, Activity mainActivity)** - Creates a new instance of the CodePush runtime, that will be used to query the service for updates via the provided deployment key. The `mainActivity` parameter should always be set to `this` when configuring your React packages list inside the `MainActivity` class. This constructor puts the CodePush runtime into "release mode", so if you want to enable debugging behavior, use the following constructor instead. |
30 | 30 |
|
31 | | -- __CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)__ - Equivalent to the previous constructor but allows you to specify whether you want the CodePush runtime to be in debug mode or not. When using this constructor, the `isDebugMode` parameter should always be set to `BuildConfig.DEBUG` in order to stay synchronized with your build type. When putting CodePush into debug mode, the following behaviors are enabled: |
| 31 | +- **CodePush(String deploymentKey, Activity mainActivity, bool isDebugMode)** - Equivalent to the previous constructor but allows you to specify whether you want the CodePush runtime to be in debug mode or not. When using this constructor, the `isDebugMode` parameter should always be set to `BuildConfig.DEBUG` in order to stay synchronized with your build type. When putting CodePush into debug mode, the following behaviors are enabled: |
32 | 32 |
|
33 | 33 | 1. Old CodePush updates aren't deleted from storage whenever a new binary is deployed to the emulator/device. This behavior enables you to deploy new binaries, without bumping the version during development, and without continuously getting the same update every time your app calls `sync`. |
34 | 34 |
|
35 | 35 | 2. The local cache that the React Native runtime maintains in debug mode is deleted whenever a CodePush update is installed. This ensures that when the app is restarted after an update is applied, you will see the expected changes. As soon as [this PR](https://github.com/facebook/react-native/pull/4738) is merged, we won't need to do this anymore. |
36 | 36 |
|
37 | | -- __CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)__ - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature. |
38 | | - |
39 | | -- __CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)__ Constructor allows you to specify CodePush Server Url. The Default value: `"https://codepush.appcenter.ms/"` is overridden by value specified in `serverUrl`. |
40 | | - |
41 | | -##### Builder |
42 | | - |
43 | | -As an alternative to constructors *you can also use `CodePushBuilder`* to setup a CodePush instance configured with *only parameters you want*. |
44 | | - |
45 | | -```java |
46 | | - @Override |
47 | | - protected List<ReactPackage> getPackages() { |
48 | | - return Arrays.<ReactPackage>asList( |
49 | | - new MainReactPackage(), |
50 | | - new CodePushBuilder("deployment-key-here",getApplicationContext()) |
51 | | - .setIsDebugMode(BuildConfig.DEBUG) |
52 | | - .setPublicKeyResourceDescriptor(R.string.publicKey) |
53 | | - .setServerUrl("https://yourcodepush.server.com") |
54 | | - .build() //return configured CodePush instance |
55 | | - ); |
56 | | - } |
57 | | -``` |
58 | | - |
59 | | -`CodePushBuilder` methods: |
60 | | - |
61 | | -* __public CodePushBuilder(String deploymentKey, Context context)__ - setup same parameters as via __CodePush(String deploymentKey, Activity mainActivity)__ |
62 | | - |
63 | | -* __public CodePushBuilder setIsDebugMode(boolean isDebugMode)__ - allows you to specify whether you want the CodePush runtime to be in debug mode or not. Default value: `false`. |
64 | | - |
65 | | -* __public CodePushBuilder setServerUrl(String serverUrl)__ - allows you to specify CodePush Server Url. Default value: `"https://codepush.appcenter.ms/"`. |
66 | | - |
67 | | -* __public CodePushBuilder setPublicKeyResourceDescriptor(int publicKeyResourceDescriptor)__ - allows you to specify Public Key resource descriptor which will be used for reading Public Key content for `strings.xml` file. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more detailed information about purpose of this parameter. |
| 37 | +- **CodePush(String deploymentKey, Context context, boolean isDebugMode, Integer publicKeyResourceDescriptor)** - Equivalent to the previous constructor, but allows you to specify the public key resource descriptor needed to read public key content. Please refer to [Code Signing](setup-android.md#code-signing-setup) section for more details about the Code Signing Feature. |
68 | 38 |
|
69 | | -* __public CodePush build()__ - return configured `CodePush` instance. |
| 39 | +- **CodePush(String deploymentKey, Context context, boolean isDebugMode, String serverUrl)** Constructor allows you to specify CodePush Server Url. The Default value: `"https://api.srcpush.com"` is overridden by value specified in `serverUrl`. |
70 | 40 |
|
71 | 41 | ##### Public Methods |
72 | 42 |
|
73 | | -- __setDeploymentKey(String deploymentKey)__ - Sets the deployment key that the app should use when querying for updates. This is a dynamic alternative to setting the deployment key in Codepush constructor/builder and/or specifying a deployment key in JS when calling `checkForUpdate` or `sync`. |
| 43 | +- **setDeploymentKey(String deploymentKey)** - Sets the deployment key that the app should use when querying for updates. This is a dynamic alternative to setting the deployment key in Codepush constructor/builder and/or specifying a deployment key in JS when calling `checkForUpdate` or `sync`. |
74 | 44 |
|
75 | 45 | ##### Static Methods |
76 | 46 |
|
77 | | -- __getBundleUrl()__ - Returns the path to the most recent version of your app's JS bundle file, assuming that the resource name is `index.android.bundle`. If your app is using a different bundle name, then use the overloaded version of this method which allows specifying it. This method has the same resolution behavior as the Objective-C equivalent described above. |
| 47 | +- **getBundleUrl()** - Returns the path to the most recent version of your app's JS bundle file, assuming that the resource name is `index.android.bundle`. If your app is using a different bundle name, then use the overloaded version of this method which allows specifying it. This method has the same resolution behavior as the Objective-C equivalent described above. |
78 | 48 |
|
79 | | -- __getBundleUrl(String bundleName)__ - Returns the path to the most recent version of your app's JS bundle file, using the specified resource name (like `index.android.bundle`). This method has the same resolution behavior as the Objective-C equivalent described above. |
| 49 | +- **getBundleUrl(String bundleName)** - Returns the path to the most recent version of your app's JS bundle file, using the specified resource name (like `index.android.bundle`). This method has the same resolution behavior as the Objective-C equivalent described above. |
80 | 50 |
|
81 | | -- __getPackageFolder()__ - Returns the path to the current update folder. |
| 51 | +- **getPackageFolder()** - Returns the path to the current update folder. |
82 | 52 |
|
83 | | -- __overrideAppVersion(String appVersionOverride)__ - Sets the version of the application's binary interface, which would otherwise default to the Play Store version specified as the `versionName` in the `build.gradle`. This should be called a single time, before the CodePush instance is constructed. |
| 53 | +- **overrideAppVersion(String appVersionOverride)** - Sets the version of the application's binary interface, which would otherwise default to the Play Store version specified as the `versionName` in the `build.gradle`. This should be called a single time, before the CodePush instance is constructed. |
0 commit comments