@appzung/react-native-code-push 5.7.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 (191) hide show
  1. package/AlertAdapter.js +24 -0
  2. package/CONTRIBUTING.md +136 -0
  3. package/CodePush.js +666 -0
  4. package/CodePush.podspec +27 -0
  5. package/LICENSE.md +13 -0
  6. package/README.md +386 -0
  7. package/RestartManager.js +59 -0
  8. package/android/app/build.gradle +31 -0
  9. package/android/app/proguard-rules.pro +25 -0
  10. package/android/app/src/main/AndroidManifest.xml +10 -0
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +395 -0
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +34 -0
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
  16. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
  17. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
  18. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
  19. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +641 -0
  20. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
  21. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
  22. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
  23. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +369 -0
  24. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
  25. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +267 -0
  26. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +236 -0
  27. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
  28. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
  29. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +190 -0
  30. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +17 -0
  31. package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
  32. package/android/build.gradle +20 -0
  33. package/android/codepush.gradle +113 -0
  34. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  35. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  36. package/android/gradle.properties +20 -0
  37. package/android/gradlew +164 -0
  38. package/android/gradlew.bat +90 -0
  39. package/android/settings.gradle +1 -0
  40. package/docs/api-android.md +65 -0
  41. package/docs/api-ios.md +31 -0
  42. package/docs/api-js.md +592 -0
  43. package/docs/multi-deployment-testing-android.md +107 -0
  44. package/docs/multi-deployment-testing-ios.md +53 -0
  45. package/docs/setup-android.md +406 -0
  46. package/docs/setup-ios.md +229 -0
  47. package/docs/setup-windows.md +65 -0
  48. package/gulpfile.js +302 -0
  49. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
  50. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
  51. package/ios/CodePush/Base64/README.md +47 -0
  52. package/ios/CodePush/CodePush.h +235 -0
  53. package/ios/CodePush/CodePush.m +1041 -0
  54. package/ios/CodePush/CodePushConfig.m +116 -0
  55. package/ios/CodePush/CodePushDownloadHandler.m +130 -0
  56. package/ios/CodePush/CodePushErrorUtils.m +20 -0
  57. package/ios/CodePush/CodePushPackage.m +598 -0
  58. package/ios/CodePush/CodePushTelemetryManager.m +175 -0
  59. package/ios/CodePush/CodePushUpdateUtils.m +376 -0
  60. package/ios/CodePush/CodePushUtils.m +9 -0
  61. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
  62. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
  63. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
  64. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
  65. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
  66. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
  67. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
  68. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
  69. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
  70. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
  71. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
  72. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
  73. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
  74. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
  75. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
  76. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
  77. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
  78. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
  79. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
  80. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
  83. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
  84. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
  85. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
  86. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
  87. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
  88. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
  89. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
  91. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
  92. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
  93. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
  94. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
  95. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
  96. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
  97. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
  101. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
  102. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
  103. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
  104. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
  105. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
  106. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
  107. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
  108. package/ios/CodePush/JWT/LICENSE +19 -0
  109. package/ios/CodePush/JWT/README.md +489 -0
  110. package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
  111. package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
  112. package/ios/CodePush/SSZipArchive/Common.h +81 -0
  113. package/ios/CodePush/SSZipArchive/README.md +1 -0
  114. package/ios/CodePush/SSZipArchive/SSZipArchive.h +76 -0
  115. package/ios/CodePush/SSZipArchive/SSZipArchive.m +691 -0
  116. package/ios/CodePush/SSZipArchive/aes/aes.h +198 -0
  117. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +541 -0
  118. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +294 -0
  119. package/ios/CodePush/SSZipArchive/aes/aeskey.c +548 -0
  120. package/ios/CodePush/SSZipArchive/aes/aesopt.h +739 -0
  121. package/ios/CodePush/SSZipArchive/aes/aestab.c +391 -0
  122. package/ios/CodePush/SSZipArchive/aes/aestab.h +173 -0
  123. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +126 -0
  124. package/ios/CodePush/SSZipArchive/aes/brg_types.h +219 -0
  125. package/ios/CodePush/SSZipArchive/aes/entropy.c +54 -0
  126. package/ios/CodePush/SSZipArchive/aes/entropy.h +16 -0
  127. package/ios/CodePush/SSZipArchive/aes/fileenc.c +144 -0
  128. package/ios/CodePush/SSZipArchive/aes/fileenc.h +121 -0
  129. package/ios/CodePush/SSZipArchive/aes/hmac.c +145 -0
  130. package/ios/CodePush/SSZipArchive/aes/hmac.h +103 -0
  131. package/ios/CodePush/SSZipArchive/aes/prng.c +155 -0
  132. package/ios/CodePush/SSZipArchive/aes/prng.h +82 -0
  133. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +103 -0
  134. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +57 -0
  135. package/ios/CodePush/SSZipArchive/aes/sha1.c +258 -0
  136. package/ios/CodePush/SSZipArchive/aes/sha1.h +73 -0
  137. package/ios/CodePush/SSZipArchive/minizip/crypt.h +130 -0
  138. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +369 -0
  139. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +175 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mztools.c +284 -0
  141. package/ios/CodePush/SSZipArchive/minizip/mztools.h +31 -0
  142. package/ios/CodePush/SSZipArchive/minizip/unzip.c +1839 -0
  143. package/ios/CodePush/SSZipArchive/minizip/unzip.h +248 -0
  144. package/ios/CodePush/SSZipArchive/minizip/zip.c +1910 -0
  145. package/ios/CodePush/SSZipArchive/minizip/zip.h +202 -0
  146. package/ios/CodePush.xcodeproj/project.pbxproj +937 -0
  147. package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  148. package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  149. package/logging.js +6 -0
  150. package/package-mixins.js +69 -0
  151. package/package.json +47 -0
  152. package/request-fetch-adapter.js +52 -0
  153. package/scripts/generateBundledResourcesHash.js +125 -0
  154. package/scripts/getFilesInFolder.js +19 -0
  155. package/scripts/postlink/android/postlink.js +87 -0
  156. package/scripts/postlink/ios/postlink.js +116 -0
  157. package/scripts/postlink/run.js +11 -0
  158. package/scripts/postunlink/android/postunlink.js +74 -0
  159. package/scripts/postunlink/ios/postunlink.js +87 -0
  160. package/scripts/postunlink/run.js +11 -0
  161. package/scripts/recordFilesBeforeBundleCommand.js +41 -0
  162. package/scripts/tools/linkToolsAndroid.js +57 -0
  163. package/scripts/tools/linkToolsIos.js +130 -0
  164. package/typings/react-native-code-push.d.ts +446 -0
  165. package/windows/CodePush/CodePush.csproj +128 -0
  166. package/windows/CodePush/CodePushUtils.cs +47 -0
  167. package/windows/CodePush/FileUtils.cs +40 -0
  168. package/windows/CodePush/Properties/AssemblyInfo.cs +29 -0
  169. package/windows/CodePush/Properties/CodePush.rd.xml +33 -0
  170. package/windows/CodePush/UpdateManager.cs +305 -0
  171. package/windows/CodePush/UpdateUtils.cs +46 -0
  172. package/windows/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
  173. package/windows/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
  174. package/windows/CodePush.Net46/CodePush.Net46.csproj +103 -0
  175. package/windows/CodePush.Net46/CodePushUtils.cs +158 -0
  176. package/windows/CodePush.Net46/FileUtils.cs +55 -0
  177. package/windows/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
  178. package/windows/CodePush.Net46/UpdateManager.cs +330 -0
  179. package/windows/CodePush.Net46/UpdateUtils.cs +70 -0
  180. package/windows/CodePush.Net46/packages.config +5 -0
  181. package/windows/CodePush.Shared/CodePush.Shared.projitems +22 -0
  182. package/windows/CodePush.Shared/CodePush.Shared.shproj +13 -0
  183. package/windows/CodePush.Shared/CodePushConstants.cs +35 -0
  184. package/windows/CodePush.Shared/CodePushNativeModule.cs +329 -0
  185. package/windows/CodePush.Shared/CodePushReactPackage.cs +235 -0
  186. package/windows/CodePush.Shared/CodePushUtils.cs +70 -0
  187. package/windows/CodePush.Shared/InstallMode.cs +9 -0
  188. package/windows/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
  189. package/windows/CodePush.Shared/SettingsManager.cs +148 -0
  190. package/windows/CodePush.Shared/TelemetryManager.cs +250 -0
  191. package/windows/CodePush.Shared/UpdateState.cs +9 -0
@@ -0,0 +1,107 @@
1
+ ### Android
2
+
3
+ > NOTE
4
+ >
5
+ > Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/Microsoft/react-native-code-push/files/1314118/rncp1004.zip).
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.
8
+
9
+ To set this up, perform the following steps:
10
+
11
+ 1. Open your app's `build.gradle` file (for example `android/app/build.gradle` in standard React Native projects)
12
+
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.
14
+
15
+ ```groovy
16
+ android {
17
+ ...
18
+ buildTypes {
19
+ debug {
20
+ ...
21
+ // 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.
22
+ buildConfigField "String", "CODEPUSH_KEY", '""'
23
+ ...
24
+ }
25
+
26
+ releaseStaging {
27
+ ...
28
+ buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
29
+ // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
30
+ // Add the following line if not already there
31
+ matchingFallbacks = ['release']
32
+ ...
33
+ }
34
+
35
+ release {
36
+ ...
37
+ buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
38
+ ...
39
+ }
40
+ }
41
+ ...
42
+ }
43
+ ```
44
+
45
+ *NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
46
+
47
+ *NOTE: The naming convention for `releaseStaging` is significant due to [this line](https://github.com/facebook/react-native/blob/e083f9a139b3f8c5552528f8f8018529ef3193b9/react.gradle#L79).*
48
+
49
+ 4. Pass the deployment key to the `CodePush` constructor via the build config you defined, as opposed to a string literal.
50
+
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
+ **For React Native v0.19 - v0.28**
67
+
68
+ Open up your `MainActivity.java` file and make the following changes:
69
+
70
+ ```java
71
+ @Override
72
+ protected List<ReactPackage> getPackages() {
73
+ return Arrays.<ReactPackage>asList(
74
+ ...
75
+ new CodePush(BuildConfig.CODEPUSH_KEY, this, BuildConfig.DEBUG), // Add/change this line.
76
+ ...
77
+ );
78
+ }
79
+ ```
80
+
81
+ *Note: If you gave your build setting a different name in your Gradle file, simply make sure to reflect that in your Java code.*
82
+
83
+ 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.
84
+
85
+ *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.*
86
+
87
+ 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:
88
+
89
+ 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`).
90
+
91
+ ```groovy
92
+ buildTypes {
93
+ debug {
94
+ applicationIdSuffix ".debug"
95
+ }
96
+ }
97
+ ```
98
+
99
+ 2. Create the `app/src/debug/res` directory structure in your app, which allows overriding resources (like strings, icons, layouts) for your debug builds
100
+
101
+ 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
102
+
103
+ 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.
104
+
105
+ 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
+
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.
@@ -0,0 +1,53 @@
1
+ ### iOS
2
+
3
+ > NOTE
4
+ >
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)
8
+
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
+
11
+ To set this up, perform the following steps:
12
+
13
+ 1. Open up your Xcode project and select your project in the `Project navigator` window
14
+
15
+ 2. Ensure the project node is selected, as opposed to one of your targets
16
+
17
+ 3. Select the `Info` tab
18
+
19
+ 4. Click the `+` button within the `Configurations` section and select `Duplicate "Release" Configuration`
20
+
21
+ ![Configuration](https://cloud.githubusercontent.com/assets/116461/16101597/088714c0-331c-11e6-9504-5469d9a59d74.png)
22
+
23
+ 5. Name the new configuration `Staging` (or whatever you prefer)
24
+
25
+ 6. Select the `Build Settings` tab
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)`
28
+
29
+ ![BuildFilesPath](https://cloud.githubusercontent.com/assets/4928157/22645377/b1d7df0e-ec77-11e6-83c6-291a27bcdb17.png)
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.*
32
+
33
+ 8. Click the `+` button on the toolbar and select `Add User-Defined Setting`
34
+
35
+ ![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
36
+
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.
38
+
39
+ ![Setting Keys](https://cloud.githubusercontent.com/assets/8598682/16821919/fc1eac4a-490d-11e6-9b11-128129c24b80.png)
40
+
41
+ *NOTE: As a reminder, you can retrieve these keys by running `code-push deployment ls <APP_NAME> -k` from your terminal.*
42
+
43
+ 10. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
44
+
45
+ ![Infoplist](https://cloud.githubusercontent.com/assets/116461/15764252/3ac8aed2-28de-11e6-8c19-2270ae9857a7.png)
46
+
47
+ And that's it! Now when you run or build your app, your staging builds will automatically be configured to sync with your `Staging` deployment, and your release builds will be configured to sync with your `Production` deployment.
48
+
49
+ *NOTE: CocoaPods users may need to run `pod install` before building with their new release configuration.*
50
+
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.*
52
+
53
+ 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.
@@ -0,0 +1,406 @@
1
+ ## Android Setup
2
+
3
+ * [Plugin Installation (Android)](#plugin-installation-android)
4
+ * [Plugin Installation (Android - RNPM)](#plugin-installation-android---rnpm)
5
+ * [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)
8
+ * [For newly created React Native application](#for-newly-created-react-native-application)
9
+ * [For existing native application](#for-existing-native-application)
10
+ * [For React Native v0.19 - v0.28](#for-react-native-v019---v028)
11
+ * [Background React Instances](#background-react-instances)
12
+ * [For React Native >= v0.29 (Background React Instances)](#for-react-native--v029-background-react-instances)
13
+ * [For React Native v0.19 - v0.28 (Background React Instances)](#for-react-native-v019---v028-background-react-instances)
14
+ * [WIX React Native Navigation applications (ver 1.x)](#wix-react-native-navigation-applications)
15
+ * [Code Signing setup](#code-signing-setup)
16
+
17
+ In order to integrate CodePush into your Android project, please perform the following steps:
18
+
19
+ ### Plugin Installation (Android)
20
+
21
+ In order to accommodate as many developer preferences as possible, the CodePush plugin supports Android installation via two mechanisms:
22
+
23
+ 1. [**RNPM**](#plugin-installation-android---rnpm) - [React Native Package Manager (RNPM)](https://github.com/rnpm/rnpm) is an awesome tool that provides the simplest installation experience possible for React Native plugins. If you're already using it, or you want to use it, then we recommend this approach.
24
+
25
+ 2. [**"Manual"**](#plugin-installation-android---manual) - If you don't want to depend on any additional tools or are fine with a few extra installation steps (it's a one-time thing), then go with this approach.
26
+
27
+ *Note: Due to a code change from the React Native repository, if your installed React Native version ranges from 0.29 to 0.32, we recommend following the manual steps to set up correctly. *
28
+
29
+ #### Plugin Installation (Android - RNPM)
30
+
31
+ 1. As of v0.27 of React Native, `rnpm link` has already been merged into the React Native CLI. Simply run:
32
+ ```
33
+ react-native link react-native-code-push
34
+ ```
35
+
36
+ If your app uses a version of React Native that is lower than v0.27, run the following:
37
+ ```
38
+ rnpm link react-native-code-push
39
+ ```
40
+
41
+ *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
+
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.
44
+
45
+ And that's it for installation using RNPM! Continue below to the [Plugin Configuration](#plugin-configuration-android) section to complete the setup.
46
+
47
+ #### Plugin Installation (Android - Manual)
48
+
49
+ 1. In your `android/settings.gradle` file, make the following additions:
50
+
51
+ ```gradle
52
+ include ':app', ':react-native-code-push'
53
+ project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
54
+ ```
55
+
56
+ 2. In your `android/app/build.gradle` file, add the `:react-native-code-push` project as a compile-time dependency:
57
+
58
+ ```gradle
59
+ ...
60
+ dependencies {
61
+ ...
62
+ compile project(':react-native-code-push')
63
+ }
64
+ ```
65
+
66
+ 3. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition underneath `react.gradle`:
67
+
68
+ ```gradle
69
+ ...
70
+ apply from: "../../node_modules/react-native/react.gradle"
71
+ apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
72
+ ...
73
+ ```
74
+
75
+ ### Plugin Configuration (Android)
76
+
77
+ *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
+
79
+ 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
+
81
+ #### For React Native >= v0.29
82
+
83
+ ##### For newly created React Native application
84
+
85
+ If you are integrating Code Push into React Native application please do the following steps:
86
+
87
+ Update the `MainApplication.java` file to use CodePush via the following changes:
88
+
89
+ ```java
90
+ ...
91
+ // 1. Import the plugin class.
92
+ import com.microsoft.codepush.react.CodePush;
93
+
94
+ public class MainApplication extends Application implements ReactApplication {
95
+
96
+ private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
97
+ ...
98
+ // 2. Override the getJSBundleFile method in order to let
99
+ // the CodePush runtime determine where to get the JS
100
+ // bundle location from on each app start
101
+ @Override
102
+ protected String getJSBundleFile() {
103
+ return CodePush.getJSBundleFile();
104
+ }
105
+
106
+ @Override
107
+ protected List<ReactPackage> getPackages() {
108
+ // 3. Instantiate an instance of the CodePush runtime and add it to the list of
109
+ // existing packages, specifying the right deployment key. If you don't already
110
+ // have it, you can run "code-push deployment ls <appName> -k" to retrieve your key.
111
+ return Arrays.<ReactPackage>asList(
112
+ new MainReactPackage(),
113
+ new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG)
114
+ );
115
+ }
116
+ };
117
+ }
118
+ ```
119
+
120
+ *NOTE: For React Native v0.49+ please be sure that `getJSMainModuleName` function in the `MainApplication.java` file determines correct URL to fetch JS bundle (used when dev support is enabled, see [this](https://github.com/facebook/react-native/blob/c7f37074ac89f7e568ca26a6bad3bdb02812c39f/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java#L124) for more details) e.g.*
121
+ ```
122
+ @Override
123
+ protected String getJSMainModuleName() {
124
+ return "index";
125
+ }
126
+ ```
127
+
128
+ ##### For existing native application
129
+
130
+ If you are integrating React Native into existing native application please do the following steps:
131
+
132
+ Update `MyReactActivity.java` (it could be named differently in your app) file to use CodePush via the following changes:
133
+
134
+ ```java
135
+ ...
136
+ // 1. Import the plugin class.
137
+ import com.microsoft.codepush.react.CodePush;
138
+
139
+ public class MyReactActivity extends Activity {
140
+ private ReactRootView mReactRootView;
141
+ private ReactInstanceManager mReactInstanceManager;
142
+
143
+ @Override
144
+ protected void onCreate(Bundle savedInstanceState) {
145
+ ...
146
+ mReactInstanceManager = ReactInstanceManager.builder()
147
+ // ...
148
+ // Add CodePush package
149
+ .addPackage(new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG))
150
+ // Get the JS Bundle File via Code Push
151
+ .setJSBundleFile(CodePush.getJSBundleFile())
152
+ // ...
153
+
154
+ .build();
155
+ mReactRootView.startReactApplication(mReactInstanceManager, "MyReactNativeApp", null);
156
+
157
+ setContentView(mReactRootView);
158
+ }
159
+
160
+ ...
161
+ }
162
+ ```
163
+
164
+ #### For React Native v0.19 - v0.28
165
+
166
+ Update the `MainActivity.java` file to use CodePush via the following changes:
167
+
168
+ ```java
169
+ ...
170
+ // 1. Import the plugin class (if you used RNPM to install the plugin, this
171
+ // should already be done for you automatically so you can skip this step).
172
+ import com.microsoft.codepush.react.CodePush;
173
+
174
+ public class MainActivity extends ReactActivity {
175
+ // 2. Override the getJSBundleFile method in order to let
176
+ // the CodePush runtime determine where to get the JS
177
+ // bundle location from on each app start
178
+ @Override
179
+ protected String getJSBundleFile() {
180
+ return CodePush.getJSBundleFile();
181
+ }
182
+
183
+ @Override
184
+ protected List<ReactPackage> getPackages() {
185
+ // 3. Instantiate an instance of the CodePush runtime and add it to the list of
186
+ // existing packages, specifying the right deployment key. If you don't already
187
+ // have it, you can run "code-push deployment ls <appName> -k" to retrieve your key.
188
+ return Arrays.<ReactPackage>asList(
189
+ new MainReactPackage(),
190
+ new CodePush("deployment-key-here", this, BuildConfig.DEBUG)
191
+ );
192
+ }
193
+
194
+ ...
195
+ }
196
+ ```
197
+
198
+ #### Background React Instances
199
+
200
+ *This section is only necessary if you're <b>explicitly</b> launching a React Native instance without an `Activity` (for example, from within a native push notification receiver). For these situations, CodePush must be told how to find your React Native instance.*
201
+
202
+ In order to update/restart your React Native instance, CodePush must be configured with a `ReactInstanceHolder` before attempting to restart an instance in the background. This is done in your `Application` implementation.
203
+
204
+ ##### For React Native >= v0.29 (Background React Instances)
205
+
206
+ Update the `MainApplication.java` file to use CodePush via the following changes:
207
+
208
+ ```java
209
+ ...
210
+ // 1. Declare your ReactNativeHost to extend ReactInstanceHolder. ReactInstanceHolder is a subset of ReactNativeHost, so no additional implementation is needed.
211
+ import com.microsoft.codepush.react.ReactInstanceHolder;
212
+
213
+ public class MyReactNativeHost extends ReactNativeHost implements ReactInstanceHolder {
214
+ // ... usual overrides
215
+ }
216
+
217
+ // 2. Provide your ReactNativeHost to CodePush.
218
+
219
+ public class MainApplication extends Application implements ReactApplication {
220
+
221
+ private final MyReactNativeHost mReactNativeHost = new MyReactNativeHost(this);
222
+
223
+ @Override
224
+ public void onCreate() {
225
+ CodePush.setReactInstanceHolder(mReactNativeHost);
226
+ super.onCreate();
227
+ }
228
+ }
229
+ ```
230
+
231
+ ##### For React Native v0.19 - v0.28 (Background React Instances)
232
+
233
+ Before v0.29, React Native did not provide a `ReactNativeHost` abstraction. If you're launching a background instance, you'll likely have built your own, which should now implement `ReactInstanceHolder`. Once that's done:
234
+
235
+ ```java
236
+ // 1. Provide your ReactInstanceHolder to CodePush.
237
+
238
+ public class MainApplication extends Application {
239
+
240
+ @Override
241
+ public void onCreate() {
242
+ // ... initialize your instance holder
243
+ CodePush.setReactInstanceHolder(myInstanceHolder);
244
+ super.onCreate();
245
+ }
246
+ }
247
+ ```
248
+
249
+ 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.
250
+
251
+ #### WIX React Native Navigation applications
252
+
253
+ If you are using [WIX React Native Navigation **version 1.x**](https://github.com/wix/react-native-navigation) based application, please do the following steps to integrate CodePush:
254
+
255
+ 1. No need to change `MainActivity.java` file, so if you are integrating CodePush to newly created RNN application it might be looking like this:
256
+
257
+ ```java
258
+ import com.facebook.react.ReactActivity;
259
+ import com.reactnativenavigation.controllers.SplashActivity;
260
+
261
+ public class MainActivity extends SplashActivity {
262
+
263
+ }
264
+ ```
265
+
266
+ 2. Update the `MainApplication.java` file to use CodePush via the following changes:
267
+
268
+ ```java
269
+ // ...
270
+ import com.facebook.react.ReactInstanceManager;
271
+
272
+ // Add CodePush imports
273
+ import com.microsoft.codepush.react.ReactInstanceHolder;
274
+ import com.microsoft.codepush.react.CodePush;
275
+
276
+ public class MainApplication extends NavigationApplication implements ReactInstanceHolder {
277
+
278
+ @Override
279
+ public boolean isDebug() {
280
+ // Make sure you are using BuildConfig from your own application
281
+ return BuildConfig.DEBUG;
282
+ }
283
+
284
+ protected List<ReactPackage> getPackages() {
285
+ // Add additional packages you require here
286
+ return Arrays.<ReactPackage>asList(
287
+ new CodePush("deployment-key-here", getApplicationContext(), BuildConfig.DEBUG)
288
+ );
289
+ }
290
+
291
+ @Override
292
+ public List<ReactPackage> createAdditionalReactPackages() {
293
+ return getPackages();
294
+ }
295
+
296
+ @Override
297
+ public String getJSBundleFile() {
298
+ // Override default getJSBundleFile method with the one CodePush is providing
299
+ return CodePush.getJSBundleFile();
300
+ }
301
+
302
+ @Override
303
+ public String getJSMainModuleName() {
304
+ return "index";
305
+ }
306
+
307
+ @Override
308
+ public ReactInstanceManager getReactInstanceManager() {
309
+ // CodePush must be told how to find React Native instance
310
+ return getReactNativeHost().getReactInstanceManager();
311
+ }
312
+ }
313
+ ```
314
+ If you are using [WIX React Native Navigation **version 2.x**](https://github.com/wix/react-native-navigation/tree/v2) based application, please do the following steps to integrate CodePush:
315
+
316
+ 1. As per React Native Navigation's documentation, `MainActivity.java` should extend `NavigationActivity`, no changes required to incorporate CodePush:
317
+
318
+ ```java
319
+ import com.reactnativenavigation.NavigationActivity;
320
+
321
+ public class MainActivity extends NavigationActivity {
322
+
323
+ }
324
+ ```
325
+
326
+ 2. Update the `MainApplication.java` file to use CodePush via the following changes:
327
+
328
+ ```java
329
+ // ...
330
+ import com.facebook.react.ReactInstanceManager;
331
+
332
+ // Add CodePush imports
333
+ import com.microsoft.codepush.react.CodePush;
334
+
335
+ public class MainApplication extends NavigationApplication {
336
+
337
+ @Override
338
+ public boolean isDebug() {
339
+ return BuildConfig.DEBUG;
340
+ }
341
+
342
+ @Override
343
+ protected ReactGateway createReactGateway() {
344
+ ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
345
+ @javax.annotation.Nullable
346
+ @Override
347
+ protected String getJSBundleFile() {
348
+ return CodePush.getJSBundleFile();
349
+ }
350
+
351
+ };
352
+ return new ReactGateway(this, isDebug(), host);
353
+ }
354
+
355
+ @Override
356
+ public List<ReactPackage> createAdditionalReactPackages() {
357
+ return Arrays.<ReactPackage>asList(
358
+ new CodePush("deployment-key-here", getApplicationContext(), isDebug())
359
+ //,MainReactPackage , etc...
360
+ }
361
+ }
362
+ ```
363
+
364
+ #### Code Signing setup
365
+
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:
367
+
368
+ 1. Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:
369
+
370
+ ```xml
371
+ <resources>
372
+ <string name="app_name">my_app</string>
373
+ <string name="CodePushPublicKey">-----BEGIN PUBLIC KEY-----
374
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtPSR9lkGzZ4FR0lxF+ZA
375
+ P6jJ8+Xi5L601BPN4QESoRVSrJM08roOCVrs4qoYqYJy3Of2cQWvNBEh8ti3FhHu
376
+ tiuLFpNdfzM4DjAw0Ti5hOTfTixqVBXTJPYpSjDh7K6tUvp9MV0l5q/Ps3se1vud
377
+ M1/X6g54lIX/QoEXTdMgR+SKXvlUIC13T7GkDHT6Z4RlwxkWkOmf2tGguRcEBL6j
378
+ ww7w/3g0kWILz7nNPtXyDhIB9WLH7MKSJWdVCZm+cAqabUfpCFo7sHiyHLnUxcVY
379
+ OTw3sz9ceaci7z2r8SZdsfjyjiDJrq69eWtvKVUpredy9HtyALtNuLjDITahdh8A
380
+ zwIDAQAB
381
+ -----END PUBLIC KEY-----</string>
382
+ </resources>
383
+ ```
384
+
385
+ 2. Configure `CodePush` instance to use this parameter
386
+
387
+ * using constructor
388
+
389
+ ```java
390
+ new CodePush(
391
+ "deployment-key",
392
+ getApplicationContext(),
393
+ BuildConfig.DEBUG,
394
+ R.string.CodePushPublicKey)
395
+ ```
396
+
397
+ or
398
+
399
+ * using builder
400
+
401
+ ```java
402
+ new CodePushBuilder("deployment-key-here",getApplicationContext())
403
+ .setIsDebugMode(BuildConfig.DEBUG)
404
+ .setPublicKeyResourceDescriptor(R.string.CodePushPublicKey)
405
+ .build()
406
+ ```