Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit dbb7f79

Browse files
ruslan-bikkininsergey-akhalkov
authored andcommitted
Update docs in terms of Code Signing feature (#988)
* Update setup-ios docs * Update android docs * Add minor fixes * Add additional fixes * Remove redundant lines * Cleaning up verbiage * Cleaned up verbiage.
1 parent d37ee85 commit dbb7f79

File tree

3 files changed

+108
-4
lines changed

3 files changed

+108
-4
lines changed

docs/api-android.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,43 @@ Constructs the CodePush client runtime and represents the `ReactPackage` instanc
1010

1111
- __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.
1212

13-
- __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:
13+
- __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:
1414

1515
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`.
1616

1717
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.
1818

19+
- __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) section for more details about Code Signing Feature.
20+
21+
##### Builder
22+
23+
As an alternative to constructors *you can also use `CodePushBuilder`* to setup a CodePush instance configured with *only parameters you want*.
24+
25+
```java
26+
@Override
27+
protected List<ReactPackage> getPackages() {
28+
return Arrays.<ReactPackage>asList(
29+
new MainReactPackage(),
30+
new CodePushBuilder("deployment-key-here",getApplicationContext())
31+
.setIsDebugMode(BuildConfig.DEBUG)
32+
.setPublicKeyResourceDescriptor(R.string.publicKey)
33+
.build() //return configured CodePush instance
34+
);
35+
}
36+
```
37+
38+
`CodePushBuilder` methods:
39+
40+
* __public CodePushBuilder(String deploymentKey, Context context)__ - setup same parameters as via __CodePush(String deploymentKey, Activity mainActivity)__
41+
42+
* __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`.
43+
44+
* __public CodePushBuilder setServerUrl(String serverUrl)__ - allows you to specify CodePush Server Url. Default value: `"https://codepush.azurewebsites.net/"`.
45+
46+
* __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](#code-signing) section for more detailed information about purpose of this parameter.
47+
48+
* __public CodePush build()__ - return configured `CodePush` instance.
49+
1950
##### Static Methods
2051

2152
- __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.

docs/setup-android.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,47 @@ public class MainApplication extends Application {
185185
```
186186

187187
In order to effectively make use of the `Staging` and `Production` deployments that were created along with your CodePush app, refer to the [multi-deployment testing](../README.md#multi-deployment-testing) docs below before actually moving your app's usage of CodePush into production.
188+
189+
#### Code Signing
190+
191+
Starting with version TODO you can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant code-push documentation section](https://github.com/Microsoft/code-push/tree/master/cli#code-signing). In order to use Public Key for Code Signing you need to do following steps:
192+
193+
1. Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:
194+
195+
```xml
196+
<resources>
197+
<string name="app_name">my_app</string>
198+
<string name="CodePushPublicKey">-----BEGIN PUBLIC KEY-----
199+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtPSR9lkGzZ4FR0lxF+ZA
200+
P6jJ8+Xi5L601BPN4QESoRVSrJM08roOCVrs4qoYqYJy3Of2cQWvNBEh8ti3FhHu
201+
tiuLFpNdfzM4DjAw0Ti5hOTfTixqVBXTJPYpSjDh7K6tUvp9MV0l5q/Ps3se1vud
202+
M1/X6g54lIX/QoEXTdMgR+SKXvlUIC13T7GkDHT6Z4RlwxkWkOmf2tGguRcEBL6j
203+
ww7w/3g0kWILz7nNPtXyDhIB9WLH7MKSJWdVCZm+cAqabUfpCFo7sHiyHLnUxcVY
204+
OTw3sz9ceaci7z2r8SZdsfjyjiDJrq69eWtvKVUpredy9HtyALtNuLjDITahdh8A
205+
zwIDAQAB
206+
-----END PUBLIC KEY-----</string>
207+
</resources>
208+
```
209+
210+
2. Configure `CodePush` instance to use this parameter
211+
212+
* using constructor
213+
214+
```java
215+
new CodePush(
216+
"deployment-key",
217+
getApplicationContext(),
218+
BuildConfig.DEBUG,
219+
R.string.CodePushPublicKey)
220+
```
221+
222+
or
223+
224+
* using builder
225+
226+
```java
227+
new CodePushBuilder("deployment-key-here",getApplicationContext())
228+
.setIsDebugMode(BuildConfig.DEBUG)
229+
.setPublicKeyResourceDescriptor(R.string.CodePushPublicKey)
230+
.build()
231+
```

docs/setup-ios.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,21 @@ And that's it! Isn't RNPM awesome? :)
3838
pod 'CodePush', :path => '../node_modules/react-native-code-push'
3939
```
4040
41-
CodePush depends on an internal copy of the `SSZipArchive` library, so if your project already includes it (either directly or via a transitive dependency), then you can install a version of CodePush which excludes it by depending specifically on the `Core` subspec:
41+
CodePush depends on an internal copy of the `SSZipArchive`, `JWT` and `Base64` libraries, so if your project already includes some of them (either directly or via a transitive dependency), then you can install a version of CodePush which excludes it by depending specifically on the needed subspecs:
4242
4343
```ruby
44+
# `SSZipArchive`, `JWT` and `Base64` already in use
4445
pod 'CodePush', :path => '../node_modules/react-native-code-push', :subspecs => ['Core']
46+
47+
# or for example
48+
49+
# `SSZipArchive` and `Base64` already in use
50+
pod 'CodePush', :path => '../node_modules/react-native-code-push', :subspecs => ['Core', 'JWT']
4551
```
4652
47-
*NOTE: The above paths needs to be relative to your app's `Podfile`, so adjust it as nec
48-
cessary.*
53+
*NOTE: The above paths needs to be relative to your app's `Podfile`, so adjust it as neccessary.*
54+
55+
*NOTE: `JWT` library should be of version 3.0.x*
4956
5057
2. Run `pod install`
5158
@@ -150,3 +157,25 @@ If you want to change the default HTTP security configuration for any of these d
150157
Before doing anything, please [read the docs][ats] first.
151158

152159
[ats]: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33
160+
161+
### Code Signing setup
162+
163+
Since version TODO you can self sign bundles during release and verify its signature before installation of update. For more info about Code Signing please refer to [relevant code-push documentation section](https://github.com/Microsoft/code-push/tree/master/cli#code-signing).
164+
165+
In order to configure Public Key for bundle verification you need to add record in `Info.plist` with name `CodePushPublicKey` and string value of public key content. Example:
166+
167+
```xml
168+
<plist version="1.0">
169+
<dict>
170+
<!-- ...other configs... -->
171+
172+
<key>CodePushPublicKey</key>
173+
<string>-----BEGIN PUBLIC KEY-----
174+
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANkWYydPuyOumR/sn2agNBVDnzyRpM16NAUpYPGxNgjSEp0etkDNgzzdzyvyl+OsAGBYF3jCxYOXozum+uV5hQECAwEAAQ==
175+
-----END PUBLIC KEY-----</string>
176+
177+
<!-- ...other configs... -->
178+
</dict>
179+
</plist>
180+
```
181+

0 commit comments

Comments
 (0)