@appzung/react-native-code-push 5.7.1 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CONTRIBUTING.md +17 -19
  2. package/CodePush.js +7 -4
  3. package/CodePush.podspec +2 -2
  4. package/README.md +62 -19
  5. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +44 -7
  6. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +0 -0
  7. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +77 -22
  8. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +15 -1
  9. package/android/codepush.gradle +1 -1
  10. package/docs/api-android.md +21 -3
  11. package/docs/api-js.md +3 -3
  12. package/docs/multi-deployment-testing-android.md +63 -22
  13. package/docs/multi-deployment-testing-ios.md +16 -10
  14. package/docs/setup-android.md +76 -17
  15. package/docs/setup-ios.md +55 -5
  16. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -0
  17. package/ios/CodePush/CodePush.m +82 -17
  18. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -0
  19. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -0
  20. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -0
  21. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -0
  22. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -0
  23. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -0
  24. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -0
  25. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -0
  26. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -0
  27. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -0
  28. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -0
  29. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -0
  30. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -0
  31. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -0
  32. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -0
  33. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -0
  34. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -0
  35. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -0
  36. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -0
  37. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -0
  38. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -0
  39. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -0
  40. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -0
  41. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -0
  42. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -0
  43. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -0
  44. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -0
  45. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -0
  46. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -0
  47. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -0
  48. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -0
  49. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -0
  50. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -0
  51. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -0
  52. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -0
  53. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -0
  54. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -0
  55. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -0
  56. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -0
  57. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -0
  58. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -0
  59. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -0
  60. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -0
  61. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -0
  62. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -0
  63. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -0
  64. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -0
  65. package/ios/CodePush/SSZipArchive/Common.h +0 -0
  66. package/ios/CodePush/SSZipArchive/SSZipArchive.h +0 -0
  67. package/ios/CodePush/SSZipArchive/SSZipArchive.m +0 -0
  68. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -0
  69. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -0
  70. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -0
  71. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -0
  72. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -0
  73. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -0
  74. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -0
  75. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -0
  76. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -0
  77. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -0
  78. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -0
  79. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -0
  80. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -0
  81. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -0
  82. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -0
  83. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -0
  84. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -0
  85. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -0
  86. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -0
  87. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -0
  88. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -0
  89. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -0
  90. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -0
  91. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -0
  92. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -0
  93. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -0
  94. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -0
  95. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -0
  96. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -0
  97. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -0
  98. package/package-mixins.js +2 -3
  99. package/package.json +36 -13
  100. package/react-native.config.js +10 -0
  101. package/request-fetch-adapter.js +1 -1
  102. package/scripts/generateBundledResourcesHash.js +1 -1
  103. package/scripts/postlink/android/postlink.js +2 -2
  104. package/scripts/postunlink/android/postunlink.js +3 -3
  105. package/scripts/tools/linkToolsAndroid.js +1 -1
  106. package/scripts/tools/linkToolsIos.js +2 -2
  107. package/tsconfig.json +14 -0
  108. package/tslint.json +32 -0
  109. package/typings/react-native-code-push.d.ts +14 -5
  110. package/RestartManager.js +0 -59
  111. package/gulpfile.js +0 -302
package/docs/api-js.md CHANGED
@@ -60,10 +60,10 @@ This decorator provides support for letting you customize its behaviour to easil
60
60
  export default MyApp;
61
61
  ```
62
62
 
63
- 2. **Silent sync everytime the app resumes**. Same as 1, except we check for updates, or apply an update if one exists every time the app returns to the foreground after being "backgrounded".
63
+ 2. **Silent sync every time the app resumes**. Same as 1, except we check for updates, or apply an update if one exists every time the app returns to the foreground after being "backgrounded".
64
64
 
65
65
  ```javascript
66
- // Sync for updates everytime the app resumes.
66
+ // Sync for updates every time the app resumes.
67
67
  class MyApp extends Component<{}> {}
68
68
  MyApp = codePush({ checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.ON_NEXT_RESUME })(MyApp);
69
69
  export default MyApp;
@@ -128,7 +128,7 @@ The `codePush` decorator accepts an "options" object that allows you to customiz
128
128
 
129
129
  * __minimumBackgroundDuration__ *(Number)* - Specifies the minimum number of seconds that the app needs to have been in the background before restarting the app. This property only applies to updates which are installed using `InstallMode.ON_NEXT_RESUME` or `InstallMode.ON_NEXT_SUSPEND`, and can be useful for getting your update in front of end users sooner, without being too obtrusive. Defaults to `0`, which has the effect of applying the update immediately after a resume or unless the app suspension is long enough to not matter, regardless how long it was in the background.
130
130
 
131
- * __updateDialog__ *(UpdateDialogOptions)* - An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, and if so, what strings to use. Defaults to `null`, which has the effect of disabling the dialog completely. Setting this to any truthy value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as overriding one or more of the default strings. Before enabling this option within an App Store-distributed app, please refer to [this note](https://github.com/Microsoft/react-native-code-push#user-content-apple-note).
131
+ * __updateDialog__ *(UpdateDialogOptions)* - An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, and if so, what strings to use. Defaults to `null`, which has the effect of disabling the dialog completely. Setting this to any truthy value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as overriding one or more of the default strings. Before enabling this option within an App Store-distributed app, please refer to [this note](https://github.com/microsoft/react-native-code-push#user-content-apple-note).
132
132
 
133
133
  The following list represents the available options and their defaults:
134
134
 
@@ -2,15 +2,73 @@
2
2
 
3
3
  > NOTE
4
4
  >
5
- > Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/Microsoft/react-native-code-push/files/1314118/rncp1004.zip).
5
+ > Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/microsoft/react-native-code-push/files/1314118/rncp1004.zip).
6
6
 
7
- The [Android Gradle plugin](http://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release), which in turn are generated as properties on the `BuildConfig` class that you can reference from your Java code. This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
7
+ The [Android Gradle plugin](https://google.github.io/android-gradle-dsl/current/index.html) allows you to define custom config settings for each "build type" (like debug, release). This mechanism allows you to easily configure your debug builds to use your CodePush staging deployment key and your release builds to use your CodePush production deployment key.
8
+
9
+ *NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
8
10
 
9
11
  To set this up, perform the following steps:
10
12
 
11
- 1. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
13
+ **For React Native >= v0.60**
14
+
15
+ 1. Open the project's app level `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
16
+
17
+ 2. Find the `android { buildTypes {} }` section and define `resValue` entries for both your `debug` and `release` build types, which reference your `Staging` and `Production` deployment keys respectively.
18
+
19
+ ```groovy
20
+ android {
21
+ ...
22
+ buildTypes {
23
+ debug {
24
+ ...
25
+ // 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.
26
+ resValue "string", "CodePushDeploymentKey", '""'
27
+ ...
28
+ }
29
+
30
+ releaseStaging {
31
+ ...
32
+ resValue "string", "CodePushDeploymentKey", '"<INSERT_STAGING_KEY>"'
33
+
34
+ // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
35
+ // Add the following line if not already there
36
+ matchingFallbacks = ['release']
37
+ ...
38
+ }
39
+
40
+ release {
41
+ ...
42
+ resValue "string", "CodePushDeploymentKey", '"<INSERT_PRODUCTION_KEY>"'
43
+ ...
44
+ }
45
+ }
46
+ ...
47
+ }
48
+ ```
49
+
50
+ *NOTE: Remember to remove the key from `strings.xml` if you are configuring the deployment key in the build process*
51
+
52
+ *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
53
+
54
+ **For React Native v0.29 - v0.59**
55
+
56
+ 1. Open up your `MainApplication.java` file and make the following changes:
57
+
58
+ ```java
59
+ @Override
60
+ protected List<ReactPackage> getPackages() {
61
+ return Arrays.<ReactPackage>asList(
62
+ ...
63
+ new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
64
+ ...
65
+ );
66
+ }
67
+ ```
12
68
 
13
- 2. 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.
69
+ 2. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
70
+
71
+ 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.
14
72
 
15
73
  ```groovy
16
74
  android {
@@ -42,27 +100,10 @@ To set this up, perform the following steps:
42
100
  }
43
101
  ```
44
102
 
45
- *NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
46
-
47
103
  *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
48
104
 
49
105
  4. Pass the deployment key to the `CodePush` constructor via the build config you defined, as opposed to a string literal.
50
106
 
51
- **For React Native >= v0.29**
52
-
53
- Open up your `MainApplication.java` file and make the following changes:
54
-
55
- ```java
56
- @Override
57
- protected List<ReactPackage> getPackages() {
58
- return Arrays.<ReactPackage>asList(
59
- ...
60
- new CodePush(BuildConfig.CODEPUSH_KEY, MainApplication.this, BuildConfig.DEBUG), // Add/change this line.
61
- ...
62
- );
63
- }
64
- ```
65
-
66
107
  **For React Native v0.19 - v0.28**
67
108
 
68
109
  Open up your `MainActivity.java` file and make the following changes:
@@ -104,4 +145,4 @@ buildTypes {
104
145
 
105
146
  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.
106
147
 
107
- 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.
148
+ 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.
@@ -3,8 +3,8 @@
3
3
  > NOTE
4
4
  >
5
5
  > Complete demos configured with "multi-deployment testing" feature are [here]:
6
- > * **without using cocoa pods**: [link](https://github.com/Microsoft/react-native-code-push/files/1259957/rncp976.copy.zip)
7
- > * **using cocoa pods**: [link](https://github.com/Microsoft/react-native-code-push/files/1172217/rncp893.copy.zip)
6
+ > * **without using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1259957/rncp976.copy.zip)
7
+ > * **using cocoa pods**: [link](https://github.com/microsoft/react-native-code-push/files/1172217/rncp893.copy.zip)
8
8
 
9
9
  Xcode allows you to define custom build settings for each "configuration" (like debug, release), which can then be referenced as the value of keys within the `Info.plist` file (like the `CodePushDeploymentKey` setting). This mechanism allows you to easily configure your builds to produce binaries, which are configured to synchronize with different CodePush deployments.
10
10
 
@@ -24,23 +24,29 @@ To set this up, perform the following steps:
24
24
 
25
25
  6. Select the `Build Settings` tab
26
26
 
27
- 7. Go to `Build Location -> Per-configuration Build Products Path -> Staging` and change `Staging` value from `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` to `$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)`
27
+ 7. Click the `+` button on the toolbar and select `Add User-Defined Setting`
28
28
 
29
- ![BuildFilesPath](https://cloud.githubusercontent.com/assets/4928157/22645377/b1d7df0e-ec77-11e6-83c6-291a27bcdb17.png)
29
+ ![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
30
30
 
31
- *NOTE: Due to https://github.com/facebook/react-native/issues/11813, we have to do this step to make it possible to use other configurations than Debug or Release on RN 0.40.0 or higher.*
31
+ Name this new setting something like `Multi_Deployment_Config`. Go to the setting and add value `$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)` for Release. After that add value `$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)` for Staging
32
32
 
33
- 8. Click the `+` button on the toolbar and select `Add User-Defined Setting`
33
+ ![MultiDeploymentConfig](https://user-images.githubusercontent.com/48414875/87178636-1d6a6500-c2e6-11ea-890d-b7773f07e503.png)
34
34
 
35
- ![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
35
+ *NOTE: For Xcode 10 and lower version: Go to Build Location -> Per-configuration Build Products Path -> Staging and change Staging value from $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)*
36
+
37
+ ![BuildFilesPath1](https://cloud.githubusercontent.com/assets/4928157/22645377/b1d7df0e-ec77-11e6-83c6-291a27bcdb17.png)
38
+
39
+ *NOTE: Due to https://github.com/facebook/react-native/issues/11813, we have to do this step to make it possible to use other configurations than Debug or Release on RN 0.40.0 or higher.*
40
+
41
+ 8. Click the `+` button again on the toolbar and select `Add User-Defined Setting`
36
42
 
37
- 9. Name this new setting something like `CODEPUSH_KEY`, expand it, and specify your `Staging` deployment key for the `Staging` config and your `Production` deployment key for the `Release` config.
43
+ Name this new setting something like `CODEPUSH_KEY`, expand it, and specify your `Staging` deployment key for the `Staging` config and your `Production` deployment key for the `Release` config.
38
44
 
39
45
  ![Setting Keys](https://cloud.githubusercontent.com/assets/8598682/16821919/fc1eac4a-490d-11e6-9b11-128129c24b80.png)
40
46
 
41
47
  *NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
42
48
 
43
- 10. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
49
+ 9. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
44
50
 
45
51
  ![Infoplist](https://cloud.githubusercontent.com/assets/116461/15764252/3ac8aed2-28de-11e6-8c19-2270ae9857a7.png)
46
52
 
@@ -48,6 +54,6 @@ And that's it! Now when you run or build your app, your staging builds will auto
48
54
 
49
55
  *NOTE: CocoaPods users may need to run `pod install` before building with their new release configuration.*
50
56
 
51
- *Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/Microsoft/react-native-code-push/issues/426) for a possible solution.*
57
+ *Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/microsoft/react-native-code-push/issues/426) for a possible solution.*
52
58
 
53
59
  Additionally, if you want to give them seperate names and/or icons, you can modify the `Product Bundle Identifier`, `Product Name` and `Asset Catalog App Icon Set Name` build settings, which will allow your staging builds to be distinguishable from release builds when installed on the same device.
@@ -1,10 +1,11 @@
1
1
  ## Android Setup
2
2
 
3
- * [Plugin Installation (Android)](#plugin-installation-android)
3
+ * [Plugin Installation and Configuration for React Native 0.60 version and above](#plugin-installation-and-configuration-for-react-native-060-version-and-above-android)
4
+ * [Plugin Installation for React Native lower than 0.60 (Android)](#plugin-installation-for-react-native-lower-than-060-android)
4
5
  * [Plugin Installation (Android - RNPM)](#plugin-installation-android---rnpm)
5
6
  * [Plugin Installation (Android - Manual)](#plugin-installation-android---manual)
6
- * [Plugin Configuration (Android)](#plugin-configuration-android)
7
- * [For React Native >= v0.29](#for-react-native--v029)
7
+ * [Plugin Configuration for React Native lower than 0.60 (Android)](#plugin-configuration-for-react-native-lower-than-060-android)
8
+ * [For React Native v0.29 - v0.59](#for-react-native-v029---v059)
8
9
  * [For newly created React Native application](#for-newly-created-react-native-application)
9
10
  * [For existing native application](#for-existing-native-application)
10
11
  * [For React Native v0.19 - v0.28](#for-react-native-v019---v028)
@@ -12,11 +13,71 @@
12
13
  * [For React Native >= v0.29 (Background React Instances)](#for-react-native--v029-background-react-instances)
13
14
  * [For React Native v0.19 - v0.28 (Background React Instances)](#for-react-native-v019---v028-background-react-instances)
14
15
  * [WIX React Native Navigation applications (ver 1.x)](#wix-react-native-navigation-applications)
15
- * [Code Signing setup](#code-signing-setup)
16
+ * [Code Signing setup](#code-signing-setup)
16
17
 
17
18
  In order to integrate CodePush into your Android project, please perform the following steps:
18
19
 
19
- ### Plugin Installation (Android)
20
+ ### Plugin Installation and Configuration for React Native 0.60 version and above (Android)
21
+
22
+ 1. In your `android/settings.gradle` file, make the following additions:
23
+
24
+ ```gradle
25
+ include ':app', ':react-native-code-push'
26
+ project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
27
+ ```
28
+
29
+ 2. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
30
+
31
+ ```gradle
32
+ ...
33
+ apply from: "../../node_modules/react-native/react.gradle"
34
+ apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
35
+ ...
36
+ ```
37
+
38
+ 3. Update the `MainApplication.java` file to use CodePush via the following changes:
39
+
40
+ ```java
41
+ ...
42
+ // 1. Import the plugin class.
43
+ import com.microsoft.codepush.react.CodePush;
44
+
45
+ public class MainApplication extends Application implements ReactApplication {
46
+
47
+ private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
48
+ ...
49
+
50
+ // 2. Override the getJSBundleFile method in order to let
51
+ // the CodePush runtime determine where to get the JS
52
+ // bundle location from on each app start
53
+ @Override
54
+ protected String getJSBundleFile() {
55
+ return CodePush.getJSBundleFile();
56
+ }
57
+ };
58
+ }
59
+ ```
60
+
61
+ 4. Add the Deployment key to `strings.xml`:
62
+
63
+ To let the CodePush runtime know which deployment it should query for updates, open your app's `strings.xml` file and add a new string named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `code-push deployment ls <appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Deployment Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. The "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
64
+
65
+ ![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
66
+
67
+ 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.
68
+
69
+ Your `strings.xml` should looks like this:
70
+
71
+ ```xml
72
+ <resources>
73
+ <string name="app_name">AppName</string>
74
+ <string moduleConfig="true" name="CodePushDeploymentKey">DeploymentKey</string>
75
+ </resources>
76
+ ```
77
+
78
+ *Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)*
79
+
80
+ ### Plugin Installation for React Native lower than 0.60 (Android)
20
81
 
21
82
  In order to accommodate as many developer preferences as possible, the CodePush plugin supports Android installation via two mechanisms:
22
83
 
@@ -40,9 +101,9 @@ In order to accommodate as many developer preferences as possible, the CodePush
40
101
 
41
102
  *Note: If you don't already have RNPM installed, you can do so by simply running `npm i -g rnpm` and then executing the above command.*
42
103
 
43
- 2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retreive this value by running `code-push deployment ls <appName> -k`, or you can choose to ignore it (by simply hitting `<ENTER>`) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end.
104
+ 2. If you're using RNPM >=1.6.0, you will be prompted for the deployment key you'd like to use. If you don't already have it, you can retrieve this value by running `code-push deployment ls <appName> -k`, or you can choose to ignore it (by simply hitting `<ENTER>`) and add it in later. To get started, we would recommend just using your `Staging` deployment key, so that you can test out the CodePush end-to-end.
44
105
 
45
- And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-android) section to complete the setup.
106
+ And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-for-react-native-lower-than-060-android) section to complete the setup.
46
107
 
47
108
  #### Plugin Installation (Android - Manual)
48
109
 
@@ -72,13 +133,13 @@ And that's it for installation using RNPM! Continue below to the [Plugin Configu
72
133
  ...
73
134
  ```
74
135
 
75
- ### Plugin Configuration (Android)
136
+ ### Plugin Configuration for React Native lower than 0.60 (Android)
76
137
 
77
138
  *NOTE: If you used RNPM or `react-native link` to automatically link the plugin, these steps have already been done for you so you may skip this section.*
78
139
 
79
140
  After installing the plugin and syncing your Android Studio project with Gradle, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this:
80
141
 
81
- #### For React Native >= v0.29
142
+ #### For React Native v0.29 - v0.59
82
143
 
83
144
  ##### For newly created React Native application
84
145
 
@@ -361,11 +422,11 @@ public class MainApplication extends NavigationApplication {
361
422
  }
362
423
  ```
363
424
 
364
- #### Code Signing setup
425
+ ### Code Signing setup
365
426
 
366
- Starting with CLI version **2.1.0** 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:
427
+ Starting with CLI version **2.1.0** 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/v3.0.1/cli#code-signing). In order to use Public Key for Code Signing you need to do following steps:
367
428
 
368
- 1. Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:
429
+ Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:
369
430
 
370
431
  ```xml
371
432
  <resources>
@@ -382,9 +443,9 @@ zwIDAQAB
382
443
  </resources>
383
444
  ```
384
445
 
385
- 2. Configure `CodePush` instance to use this parameter
446
+ #### For React Native <= v0.60 you should configure the `CodePush` instance to use this parameter using one of the following approaches
386
447
 
387
- * using constructor
448
+ ##### Using constructor
388
449
 
389
450
  ```java
390
451
  new CodePush(
@@ -394,9 +455,7 @@ new CodePush(
394
455
  R.string.CodePushPublicKey)
395
456
  ```
396
457
 
397
- or
398
-
399
- * using builder
458
+ ##### Using builder
400
459
 
401
460
  ```java
402
461
  new CodePushBuilder("deployment-key-here",getApplicationContext())
package/docs/setup-ios.md CHANGED
@@ -1,8 +1,58 @@
1
1
  ## iOS Setup
2
2
 
3
3
  Once you've acquired the CodePush plugin, you need to integrate it into the Xcode project of your React Native app and configure it correctly. To do this, take the following steps:
4
+
5
+ ### Plugin Installation and Configuration for React Native 0.60 version and above (iOS)
4
6
 
5
- ### Plugin Installation (iOS)
7
+ 1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies.
8
+
9
+ 2. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers:
10
+
11
+ ```objective-c
12
+ #import <CodePush/CodePush.h>
13
+ ```
14
+
15
+ 3. Find the following line of code, which sets the source URL for bridge for production releases:
16
+
17
+ ```objective-c
18
+ return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
19
+ ```
20
+
21
+ 4. Replace it with this line:
22
+
23
+ ```objective-c
24
+ return [CodePush bundleURL];
25
+ ```
26
+ This change configures your app to always load the most recent version of your app's JS bundle. On the first launch, this will correspond to the file that was compiled with the app. However, after an update has been pushed via CodePush, this will return the location of the most recently installed update.
27
+
28
+ *NOTE: The `bundleURL` method assumes your app's JS bundle is named `main.jsbundle`. If you have configured your app to use a different file name, simply call the `bundleURLForResource:` method (which assumes you're using the `.jsbundle` extension) or `bundleURLForResource:withExtension:` method instead, in order to overwrite that default behavior*
29
+
30
+ Typically, you're only going to want to use CodePush to resolve your JS bundle location within release builds, and therefore, we recommend using the `DEBUG` pre-processor macro to dynamically switch between using the packager server and CodePush, depending on whether you are debugging or not. This will make it much simpler to ensure you get the right behavior you want in production, while still being able to use the Chrome Dev Tools, live reload, etc. at debug-time.
31
+
32
+ Your `sourceURLForBridge` method should look like this:
33
+
34
+ ```objective-c
35
+ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
36
+ {
37
+ #if DEBUG
38
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
39
+ #else
40
+ return [CodePush bundleURL];
41
+ #endif
42
+ }
43
+ ```
44
+
45
+ 5. Add the Deployment key to `Info.plist`:
46
+
47
+ To let the CodePush runtime know which deployment it should query for updates against, open your app's `Info.plist` file and add a new entry named `CodePushDeploymentKey`, whose value is the key of the deployment you want to configure this app against (like the key for the `Staging` deployment for the `FooBar` app). You can retrieve this value by running `code-push deployment ls <appName> -k` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `Deployment Key` column which corresponds to the deployment you want to use (see below). Note that using the deployment's name (like Staging) will not work. That "friendly name" is intended only for authenticated management usage from the CLI, and not for public consumption within your app.
48
+
49
+ ![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
50
+
51
+ 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.
52
+
53
+ *Note: If you need to dynamically use a different deployment, you can also override your deployment key in JS code using [Code-Push options](./api-js.md#CodePushOptions)*
54
+
55
+ ### Plugin Installation for React Native lower than 0.60 (iOS)
6
56
 
7
57
  In order to accommodate as many developer preferences as possible, the CodePush plugin supports iOS installation via three mechanisms:
8
58
 
@@ -85,7 +135,7 @@ And that's it! Isn't RNPM awesome? :)
85
135
  *Note: Alternatively, if you prefer, you can add the `-lz` flag to the `Other Linker Flags` field in the `Linking` section of the `Build Settings`.*
86
136
 
87
137
 
88
- ### Plugin Configuration (iOS)
138
+ ### Plugin Configuration for React Native lower than 0.60 (iOS)
89
139
 
90
140
  *NOTE: If you used RNPM or `react-native link` to automatically link the plugin, these steps have already been done for you so you may skip this section.*
91
141
 
@@ -97,7 +147,7 @@ Once your Xcode project has been setup to build/link the CodePush plugin, you ne
97
147
  #import <CodePush/CodePush.h>
98
148
  ```
99
149
 
100
- For React Native 0.59 and above:
150
+ For React Native 0.59 - 0.59.10:
101
151
 
102
152
  2. Find the following line of code, which sets the source URL for bridge for production releases:
103
153
 
@@ -131,7 +181,7 @@ This change configures your app to always load the most recent version of your a
131
181
 
132
182
  Typically, you're only going to want to use CodePush to resolve your JS bundle location within release builds, and therefore, we recommend using the `DEBUG` pre-processor macro to dynamically switch between using the packager server and CodePush, depending on whether you are debugging or not. This will make it much simpler to ensure you get the right behavior you want in production, while still being able to use the Chrome Dev Tools, live reload, etc. at debug-time.
133
183
 
134
- For React Native 0.59 and above:
184
+ For React Native 0.59 - 0.59.10:
135
185
 
136
186
  ```objective-c
137
187
  - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
@@ -208,7 +258,7 @@ Before doing anything, please [read the docs][ats] first.
208
258
 
209
259
  ### Code Signing setup
210
260
 
211
- Starting with CLI version **2.1.0** 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).
261
+ Starting with CLI version **2.1.0** 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/v3.0.1/cli#code-signing).
212
262
 
213
263
  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:
214
264
 
File without changes
@@ -31,6 +31,10 @@
31
31
  long long _latestExpectedContentLength;
32
32
  long long _latestReceivedConentLength;
33
33
  BOOL _didUpdateProgress;
34
+
35
+ BOOL _allowed;
36
+ BOOL _restartInProgress;
37
+ NSMutableArray *_restartQueue;
34
38
  }
35
39
 
36
40
  RCT_EXPORT_MODULE()
@@ -369,8 +373,11 @@ static NSString *const LatestRollbackCountKey = @"count";
369
373
 
370
374
  - (instancetype)init
371
375
  {
376
+ _allowed = YES;
377
+ _restartInProgress = NO;
378
+ _restartQueue = [NSMutableArray arrayWithCapacity:1];
379
+
372
380
  self = [super init];
373
-
374
381
  if (self) {
375
382
  [self initializeUpdateAfterRestart];
376
383
  }
@@ -642,10 +649,6 @@ static NSString *const LatestRollbackCountKey = @"count";
642
649
  // a resume-based update still pending installation.
643
650
  - (void)applicationWillEnterForeground
644
651
  {
645
- if (_appSuspendTimer) {
646
- [_appSuspendTimer invalidate];
647
- _appSuspendTimer = nil;
648
- }
649
652
  // Determine how long the app was in the background and ensure
650
653
  // that it meets the minimum duration amount of time.
651
654
  int durationInBackground = 0;
@@ -653,8 +656,18 @@ static NSString *const LatestRollbackCountKey = @"count";
653
656
  durationInBackground = [[NSDate date] timeIntervalSinceDate:_lastResignedDate];
654
657
  }
655
658
 
656
- if (durationInBackground >= _minimumBackgroundDuration) {
657
- [self loadBundle];
659
+ if (_installMode == CodePushInstallModeOnNextSuspend) {
660
+ // We shouldn't use loadBundle in this case, because _appSuspendTimer will call loadBundleOnTick.
661
+ // We should cancel timer for _appSuspendTimer because otherwise, we would call loadBundle two times.
662
+ if (durationInBackground < _minimumBackgroundDuration) {
663
+ [_appSuspendTimer invalidate];
664
+ _appSuspendTimer = nil;
665
+ }
666
+ } else {
667
+ // For resume install mode.
668
+ if (durationInBackground >= _minimumBackgroundDuration) {
669
+ [self restartAppInternal:NO];
670
+ }
658
671
  }
659
672
  }
660
673
 
@@ -674,7 +687,7 @@ static NSString *const LatestRollbackCountKey = @"count";
674
687
  }
675
688
 
676
689
  -(void)loadBundleOnTick:(NSTimer *)timer {
677
- [self loadBundle];
690
+ [self restartAppInternal:NO];
678
691
  }
679
692
 
680
693
  #pragma mark - JavaScript-exported module methods (Public)
@@ -746,6 +759,33 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
746
759
  }];
747
760
  }
748
761
 
762
+ - (void)restartAppInternal:(BOOL)onlyIfUpdateIsPending
763
+ {
764
+ if (_restartInProgress) {
765
+ CPLog(@"Restart request queued until the current restart is completed.");
766
+ [_restartQueue addObject:@(onlyIfUpdateIsPending)];
767
+ return;
768
+ } else if (!_allowed) {
769
+ CPLog(@"Restart request queued until restarts are re-allowed.");
770
+ [_restartQueue addObject:@(onlyIfUpdateIsPending)];
771
+ return;
772
+ }
773
+
774
+ _restartInProgress = YES;
775
+ if (!onlyIfUpdateIsPending || [[self class] isPendingUpdate:nil]) {
776
+ [self loadBundle];
777
+ CPLog(@"Restarting app.");
778
+ return;
779
+ }
780
+
781
+ _restartInProgress = NO;
782
+ if ([_restartQueue count] > 0) {
783
+ BOOL buf = [_restartQueue valueForKey: @"@firstObject"];
784
+ [_restartQueue removeObjectAtIndex:0];
785
+ [self restartAppInternal:buf];
786
+ }
787
+ }
788
+
749
789
  /*
750
790
  * This is the native side of the CodePush.getConfiguration method. It isn't
751
791
  * currently exposed via the "react-native-code-push" module, and is used
@@ -895,6 +935,7 @@ RCT_EXPORT_METHOD(setLatestRollbackInfo:(NSString *)packageHash
895
935
  reject:(RCTPromiseRejectBlock)reject)
896
936
  {
897
937
  [[self class] setLatestRollbackInfo:packageHash];
938
+ resolve(nil);
898
939
  }
899
940
 
900
941
 
@@ -932,6 +973,37 @@ RCT_EXPORT_METHOD(notifyApplicationReady:(RCTPromiseResolveBlock)resolve
932
973
  resolve(nil);
933
974
  }
934
975
 
976
+ RCT_EXPORT_METHOD(allow:(RCTPromiseResolveBlock)resolve
977
+ rejecter:(RCTPromiseRejectBlock)reject)
978
+ {
979
+ CPLog(@"Re-allowing restarts.");
980
+ _allowed = YES;
981
+
982
+ if ([_restartQueue count] > 0) {
983
+ CPLog(@"Executing pending restart.");
984
+ BOOL buf = [_restartQueue valueForKey: @"@firstObject"];
985
+ [_restartQueue removeObjectAtIndex:0];
986
+ [self restartAppInternal:buf];
987
+ }
988
+
989
+ resolve(nil);
990
+ }
991
+
992
+ RCT_EXPORT_METHOD(clearPendingRestart:(RCTPromiseResolveBlock)resolve
993
+ rejecter:(RCTPromiseRejectBlock)reject)
994
+ {
995
+ [_restartQueue removeAllObjects];
996
+ resolve(nil);
997
+ }
998
+
999
+ RCT_EXPORT_METHOD(disallow:(RCTPromiseResolveBlock)resolve
1000
+ rejecter:(RCTPromiseRejectBlock)reject)
1001
+ {
1002
+ CPLog(@"Disallowing restarts.");
1003
+ _allowed = NO;
1004
+ resolve(nil);
1005
+ }
1006
+
935
1007
  /*
936
1008
  * This method is the native side of the CodePush.restartApp() method.
937
1009
  */
@@ -939,15 +1011,8 @@ RCT_EXPORT_METHOD(restartApp:(BOOL)onlyIfUpdateIsPending
939
1011
  resolve:(RCTPromiseResolveBlock)resolve
940
1012
  rejecter:(RCTPromiseRejectBlock)reject)
941
1013
  {
942
- // If this is an unconditional restart request, or there
943
- // is current pending update, then reload the app.
944
- if (!onlyIfUpdateIsPending || [[self class] isPendingUpdate:nil]) {
945
- [self loadBundle];
946
- resolve(@(YES));
947
- return;
948
- }
949
-
950
- resolve(@(NO));
1014
+ [self restartAppInternal:onlyIfUpdateIsPending];
1015
+ resolve(nil);
951
1016
  }
952
1017
 
953
1018
  /*