@swyng/react-native-code-push 1.0.0

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 (239) hide show
  1. package/AlertAdapter.js +24 -0
  2. package/CLAUDE.md +57 -0
  3. package/CONTRIBUTING.md +134 -0
  4. package/CodePush.js +671 -0
  5. package/CodePush.podspec +28 -0
  6. package/LICENSE.md +13 -0
  7. package/README.md +323 -0
  8. package/SECURITY.md +24 -0
  9. package/android/app/build.gradle +48 -0
  10. package/android/app/proguard-rules.pro +33 -0
  11. package/android/app/src/main/AndroidManifest.xml +5 -0
  12. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePush.java +426 -0
  13. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushConstants.java +35 -0
  14. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushDialog.java +102 -0
  15. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushInstallMode.java +16 -0
  16. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
  17. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushInvalidUpdateException.java +7 -0
  18. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushMalformedDataException.java +12 -0
  19. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushNativeModule.java +781 -0
  20. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushNotInitializedException.java +12 -0
  21. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushTelemetryManager.java +175 -0
  22. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUnknownException.java +12 -0
  23. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUpdateManager.java +383 -0
  24. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUpdateState.java +15 -0
  25. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUpdateUtils.java +275 -0
  26. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUtils.java +238 -0
  27. package/android/app/src/main/java/com/swyngpush/codepush/react/DownloadProgress.java +30 -0
  28. package/android/app/src/main/java/com/swyngpush/codepush/react/DownloadProgressCallback.java +5 -0
  29. package/android/app/src/main/java/com/swyngpush/codepush/react/FileUtils.java +203 -0
  30. package/android/app/src/main/java/com/swyngpush/codepush/react/ReactHostHolder.java +11 -0
  31. package/android/app/src/main/java/com/swyngpush/codepush/react/SettingsManager.java +173 -0
  32. package/android/app/src/main/java/com/swyngpush/codepush/react/TLSSocketFactory.java +72 -0
  33. package/android/build.gradle +23 -0
  34. package/android/codepush.gradle +162 -0
  35. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  36. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  37. package/android/gradle.properties +18 -0
  38. package/android/gradlew +164 -0
  39. package/android/gradlew.bat +90 -0
  40. package/android/settings.gradle +2 -0
  41. package/docs/LOAD_BUNDLE_DELAY_ANALYSIS.md +68 -0
  42. package/docs/api-android.md +52 -0
  43. package/docs/api-ios.md +31 -0
  44. package/docs/api-js.md +592 -0
  45. package/docs/multi-deployment-testing-android.md +55 -0
  46. package/docs/multi-deployment-testing-ios.md +59 -0
  47. package/docs/setup-android.md +121 -0
  48. package/docs/setup-ios.md +141 -0
  49. package/docs/setup-windows.md +121 -0
  50. package/expo.js +347 -0
  51. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
  52. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
  53. package/ios/CodePush/Base64/README.md +47 -0
  54. package/ios/CodePush/CodePush.h +235 -0
  55. package/ios/CodePush/CodePush.m +1131 -0
  56. package/ios/CodePush/CodePushConfig.m +115 -0
  57. package/ios/CodePush/CodePushDownloadHandler.m +130 -0
  58. package/ios/CodePush/CodePushErrorUtils.m +20 -0
  59. package/ios/CodePush/CodePushPackage.m +602 -0
  60. package/ios/CodePush/CodePushTelemetryManager.m +175 -0
  61. package/ios/CodePush/CodePushUpdateUtils.m +376 -0
  62. package/ios/CodePush/CodePushUtils.m +9 -0
  63. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
  64. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
  65. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
  66. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
  67. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
  68. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
  69. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
  70. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
  71. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
  72. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
  73. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
  74. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
  75. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
  76. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
  77. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
  78. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
  79. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
  80. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
  83. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
  84. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
  85. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
  86. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
  87. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
  88. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
  89. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
  91. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
  92. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
  93. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
  94. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
  95. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
  96. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
  97. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
  101. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
  102. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
  103. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
  104. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
  105. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
  106. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
  107. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
  108. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
  109. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
  110. package/ios/CodePush/JWT/LICENSE +19 -0
  111. package/ios/CodePush/JWT/README.md +489 -0
  112. package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
  113. package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
  114. package/ios/CodePush/SSZipArchive/Info.plist +26 -0
  115. package/ios/CodePush/SSZipArchive/README.md +1 -0
  116. package/ios/CodePush/SSZipArchive/SSZipArchive.h +178 -0
  117. package/ios/CodePush/SSZipArchive/SSZipArchive.m +1496 -0
  118. package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
  119. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
  120. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
  121. package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
  122. package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
  123. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
  124. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
  125. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
  126. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
  127. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
  128. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
  129. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
  130. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
  131. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
  132. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
  133. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
  134. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
  135. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
  136. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
  137. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
  138. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
  139. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
  141. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
  142. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
  143. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
  144. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
  145. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
  146. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
  147. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
  148. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
  149. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
  150. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
  151. package/ios/CodePush.xcodeproj/project.pbxproj +1052 -0
  152. package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  153. package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  154. package/ios/PrivacyInfo.xcprivacy +31 -0
  155. package/logging.js +6 -0
  156. package/package-mixins.js +68 -0
  157. package/package.json +91 -0
  158. package/react-native.config.js +11 -0
  159. package/request-fetch-adapter.js +52 -0
  160. package/scripts/generateBundledResourcesHash.js +125 -0
  161. package/scripts/getFilesInFolder.js +19 -0
  162. package/scripts/postlink/android/postlink.js +87 -0
  163. package/scripts/postlink/ios/postlink.js +116 -0
  164. package/scripts/postlink/run.js +11 -0
  165. package/scripts/postunlink/android/postunlink.js +74 -0
  166. package/scripts/postunlink/ios/postunlink.js +87 -0
  167. package/scripts/postunlink/run.js +11 -0
  168. package/scripts/recordFilesBeforeBundleCommand.js +41 -0
  169. package/scripts/tools/linkToolsAndroid.js +57 -0
  170. package/scripts/tools/linkToolsIos.js +130 -0
  171. package/tsconfig.json +17 -0
  172. package/tslint.json +32 -0
  173. package/typings/react-native-code-push.d.ts +455 -0
  174. package/windows/CodePush/.!12419!CodePushNativeModule.h +154 -0
  175. package/windows/CodePush/.!12440!CodePushNativeModule.h +154 -0
  176. package/windows/CodePush/CodePush.def +3 -0
  177. package/windows/CodePush/CodePush.vcxproj +198 -0
  178. package/windows/CodePush/CodePush.vcxproj.filters +91 -0
  179. package/windows/CodePush/CodePushConfig.cpp +99 -0
  180. package/windows/CodePush/CodePushConfig.h +66 -0
  181. package/windows/CodePush/CodePushConfig.idl +12 -0
  182. package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
  183. package/windows/CodePush/CodePushDownloadHandler.h +32 -0
  184. package/windows/CodePush/CodePushNativeModule.cpp +934 -0
  185. package/windows/CodePush/CodePushNativeModule.h +247 -0
  186. package/windows/CodePush/CodePushPackage.cpp +456 -0
  187. package/windows/CodePush/CodePushPackage.h +49 -0
  188. package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
  189. package/windows/CodePush/CodePushTelemetryManager.h +29 -0
  190. package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
  191. package/windows/CodePush/CodePushUpdateUtils.h +38 -0
  192. package/windows/CodePush/CodePushUtils.cpp +29 -0
  193. package/windows/CodePush/CodePushUtils.h +18 -0
  194. package/windows/CodePush/FileUtils.cpp +131 -0
  195. package/windows/CodePush/FileUtils.h +28 -0
  196. package/windows/CodePush/PropertySheet.props +16 -0
  197. package/windows/CodePush/ReactPackageProvider.cpp +15 -0
  198. package/windows/CodePush/ReactPackageProvider.h +22 -0
  199. package/windows/CodePush/ReactPackageProvider.idl +9 -0
  200. package/windows/CodePush/miniz/LICENSE +22 -0
  201. package/windows/CodePush/miniz/miniz.c +7657 -0
  202. package/windows/CodePush/miniz/miniz.h +1338 -0
  203. package/windows/CodePush/miniz/readme.md +37 -0
  204. package/windows/CodePush/packages.config +4 -0
  205. package/windows/CodePush/pch.cpp +1 -0
  206. package/windows/CodePush/pch.h +4 -0
  207. package/windows-legacy/CodePush/CodePush.csproj +128 -0
  208. package/windows-legacy/CodePush/CodePushUtils.cs +47 -0
  209. package/windows-legacy/CodePush/FileUtils.cs +40 -0
  210. package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +29 -0
  211. package/windows-legacy/CodePush/Properties/CodePush.rd.xml +33 -0
  212. package/windows-legacy/CodePush/UpdateManager.cs +305 -0
  213. package/windows-legacy/CodePush/UpdateUtils.cs +46 -0
  214. package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
  215. package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
  216. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +103 -0
  217. package/windows-legacy/CodePush.Net46/CodePushUtils.cs +158 -0
  218. package/windows-legacy/CodePush.Net46/FileUtils.cs +55 -0
  219. package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
  220. package/windows-legacy/CodePush.Net46/UpdateManager.cs +330 -0
  221. package/windows-legacy/CodePush.Net46/UpdateUtils.cs +70 -0
  222. package/windows-legacy/CodePush.Net46/packages.config +5 -0
  223. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
  224. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
  225. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
  226. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
  227. package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
  228. package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
  229. package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +22 -0
  230. package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +13 -0
  231. package/windows-legacy/CodePush.Shared/CodePushConstants.cs +35 -0
  232. package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +329 -0
  233. package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +235 -0
  234. package/windows-legacy/CodePush.Shared/CodePushUtils.cs +70 -0
  235. package/windows-legacy/CodePush.Shared/InstallMode.cs +9 -0
  236. package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
  237. package/windows-legacy/CodePush.Shared/SettingsManager.cs +148 -0
  238. package/windows-legacy/CodePush.Shared/TelemetryManager.cs +250 -0
  239. package/windows-legacy/CodePush.Shared/UpdateState.cs +9 -0
@@ -0,0 +1,55 @@
1
+ ### Android
2
+
3
+ > NOTE
4
+ >
5
+ > Complete demo configured with "multi-deployment testing" feature is [here](https://github.com/swyngpush/react-native/files/1314118/rncp1004.zip).
6
+
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 `npx @swyng/cli app ls_deployment -n <AppName> -k (Show deployment key)` from your terminal.*
10
+
11
+ To set this up, perform the following steps:
12
+
13
+ **For React Native >= v0.76**
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
+
55
+ 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,59 @@
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/swyngpush/react-native/files/1259957/rncp976.copy.zip)
7
+ > * **using cocoa pods**: [link](https://github.com/swyngpush/react-native/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. Click the `+` button on the toolbar and select `Add User-Defined Setting`
28
+
29
+ ![Setting](https://cloud.githubusercontent.com/assets/116461/15764165/a16dbe30-28dd-11e6-94f2-fa3b7eb0c7de.png)
30
+
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
+
33
+ ![MultiDeploymentConfig](https://user-images.githubusercontent.com/48414875/87178636-1d6a6500-c2e6-11ea-890d-b7773f07e503.png)
34
+
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`
42
+
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.
44
+
45
+ ![Setting Keys](https://cloud.githubusercontent.com/assets/8598682/16821919/fc1eac4a-490d-11e6-9b11-128129c24b80.png)
46
+
47
+ *NOTE: As a reminder, you can retrieve these keys by running `npx @swyng/cli app ls_deployment -n <AppName> -k (Show deployment key)` from your terminal.*
48
+
49
+ 9. Open your project's `Info.plist` file and change the value of your `CodePushDeploymentKey` entry to `$(CODEPUSH_KEY)`
50
+
51
+ ![Infoplist](https://cloud.githubusercontent.com/assets/116461/15764252/3ac8aed2-28de-11e6-8c19-2270ae9857a7.png)
52
+
53
+ 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.
54
+
55
+ *NOTE: CocoaPods users may need to run `pod install` before building with their new release configuration.*
56
+
57
+ *Note: If you encounter the error message `ld: library not found for ...`, please consult [this issue](https://github.com/swyngpush/react-native/issues/426) for a possible solution.*
58
+
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.
@@ -0,0 +1,121 @@
1
+ ## Android Setup
2
+
3
+ - [Android Setup](#android-setup)
4
+ - [Plugin Installation and Configuration for React Native 0.76 version and above (Android)](#plugin-installation-and-configuration-for-react-native-076-version-and-above-android)
5
+ - [Expo Integration](#expo-integration)
6
+
7
+ In order to integrate CodePush into your Android project, please perform the following steps:
8
+
9
+ ### Plugin Installation and Configuration for React Native 0.76 version and above (Android)
10
+
11
+
12
+ 1. In your `android/app/build.gradle` file, add the `codepush.gradle` file as an additional build task definition to the end of the file:
13
+
14
+ ```gradle
15
+ ...
16
+ apply from: "../../node_modules/@swyng/react-native-code-push/android/codepush.gradle"
17
+ ...
18
+ ```
19
+
20
+ 2. Update the `MainApplication` file to use CodePush via the following changes:
21
+
22
+ For React Native 0.76 to 0.81: update the `MainApplication.kt`
23
+
24
+ **Important! : PackageList must be instantiated only one in application lifetime.**
25
+
26
+ ```kotlin
27
+ ...
28
+ // 1. Import the plugin class.
29
+ import com.microsoft.codepush.react.CodePush
30
+
31
+ class MainApplication : Application(), ReactApplication {
32
+ override val reactNativeHost: ReactNativeHost =
33
+ object : DefaultReactNativeHost(this) {
34
+ override fun getPackages(): List<ReactPackage> = PackageList(this).packages.apply {
35
+ // Packages that cannot be autolinked yet can be added manually here, for example:
36
+ // add(MyReactNativePackage())
37
+ }
38
+
39
+ // 2. Override the getJSBundleFile method in order to let
40
+ // the CodePush runtime determine where to get the JS
41
+ // bundle location from on each app start
42
+ override fun getJSBundleFile(): String {
43
+ return CodePush.getJSBundleFile()
44
+ }
45
+ };
46
+ }
47
+
48
+ For React Native 0.82 and above: update the `MainApplication.kt` as follows:
49
+
50
+ ```kotlin
51
+ ...
52
+ // 1. Import the plugin class.
53
+ import com.microsoft.codepush.react.CodePush
54
+
55
+ class MainApplication : Application(), ReactApplication {
56
+
57
+ override val reactHost: ReactHost by lazy {
58
+ getDefaultReactHost(
59
+ context = applicationContext,
60
+ packageList =
61
+ PackageList(this).packages.apply {
62
+ // Packages that cannot be autolinked yet can be added manually here, for example:
63
+ // add(MyReactNativePackage())
64
+ },
65
+ // 2. RN 0.82+ uses ReactHost config instead of overriding getJSBundleFile().
66
+ // Set jsBundleFilePath to CodePush so CodePush resolves the JS bundle path
67
+ // at startup (OTA update if available, fallback to bundled JS otherwise).
68
+ jsBundleFilePath = CodePush.getJSBundleFile(),
69
+ )
70
+ }
71
+ }
72
+ ```
73
+
74
+
75
+ 3. Add the Deployment key to `strings.xml`:
76
+
77
+ 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 `npx @swyng/cli app ls_deployment -n <AppName> -k (Show deployment key)` in the CodePush CLI (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `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.
78
+
79
+ 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.
80
+
81
+ Your `strings.xml` should looks like this:
82
+
83
+ ```xml
84
+ <resources>
85
+ <string name="app_name">AppName</string>
86
+ <string moduleConfig="true" name="CodePushDeploymentKey">DeploymentKey</string>
87
+ </resources>
88
+ ```
89
+
90
+ *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)*
91
+
92
+
93
+ 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.
94
+
95
+
96
+
97
+ ### Code Signing setup
98
+
99
+ 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/swyngpush/code-push/tree/v3.0.1/cli#code-signing). In order to use Public Key for Code Signing you need to do following steps:
100
+
101
+ Add `CodePushPublicKey` string item to `/path_to_your_app/android/app/src/main/res/values/strings.xml`. It may looks like this:
102
+
103
+ ```xml
104
+ <resources>
105
+ <string name="app_name">my_app</string>
106
+ <string name="CodePushPublicKey">-----BEGIN PUBLIC KEY-----
107
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtPSR9lkGzZ4FR0lxF+ZA
108
+ P6jJ8+Xi5L601BPN4QESoRVSrJM08roOCVrs4qoYqYJy3Of2cQWvNBEh8ti3FhHu
109
+ tiuLFpNdfzM4DjAw0Ti5hOTfTixqVBXTJPYpSjDh7K6tUvp9MV0l5q/Ps3se1vud
110
+ M1/X6g54lIX/QoEXTdMgR+SKXvlUIC13T7GkDHT6Z4RlwxkWkOmf2tGguRcEBL6j
111
+ ww7w/3g0kWILz7nNPtXyDhIB9WLH7MKSJWdVCZm+cAqabUfpCFo7sHiyHLnUxcVY
112
+ OTw3sz9ceaci7z2r8SZdsfjyjiDJrq69eWtvKVUpredy9HtyALtNuLjDITahdh8A
113
+ zwIDAQAB
114
+ -----END PUBLIC KEY-----</string>
115
+ </resources>
116
+ ```
117
+
118
+ ### Expo Integration
119
+ 1. A pure expo react-native is not supported yet. We are planning to look into this after a while. See https://github.com/CodePushNext/react-native-code-push/issues/5
120
+ 2. A bare react-native app with expo sdk is supported, but you have to initialize rn app without `ReactNativeHostWrapper` of expo. It seems `ReactNativeHostWrapper` overrides `getJsBundleFile` internally, which prevents `CodePush` from being configured correctly.
121
+ https://github.com/expo/expo/issues/25865
@@ -0,0 +1,141 @@
1
+ ## iOS Setup
2
+
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.76 version and above (iOS)
6
+
7
+ 1. Run `cd ios && pod install && cd ..` to install all the necessary CocoaPods dependencies.
8
+
9
+ 2. Change bundleUrl on AppDelegate file.
10
+
11
+ **If you're using objective-c:**
12
+ 1. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers:
13
+
14
+ ```objective-c
15
+ #import <CodePush/CodePush.h>
16
+ ```
17
+
18
+ 2. Find the following line of code, which sets the source URL for bridge for production releases:
19
+
20
+ ```objective-c
21
+ return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
22
+ ```
23
+
24
+ 3. Replace it with this line:
25
+
26
+ ```objective-c
27
+ return [CodePush bundleURL];
28
+ ```
29
+ 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.
30
+
31
+ *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*
32
+
33
+ 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.
34
+
35
+ Your `sourceURLForBridge` method should look like this:
36
+
37
+ ```objective-c
38
+ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
39
+ {
40
+ #if DEBUG
41
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
42
+ #else
43
+ return [CodePush bundleURL];
44
+ #endif
45
+ }
46
+ ```
47
+
48
+ **If you're using Swift:**
49
+ 1. Open up the `AppDelegate.swift` file, and add an import statement for the CodePush headers:
50
+ ```swift
51
+ import CodePush
52
+ ```
53
+
54
+ 2. Find the following line of code, which sets the source URL for bridge for production release:
55
+ ```swift
56
+ Bundle.main.url(forResource: "main", withExtension: "jsbundle")
57
+ ```
58
+ 3. Replace it with this line:
59
+ ```swift
60
+ CodePush.bundleURL()
61
+ ```
62
+
63
+ Your `bundleUrl` method should look like this:
64
+ ```swift
65
+ override func bundleURL() -> URL? {
66
+ #if DEBUG
67
+ RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
68
+ #else
69
+ CodePush.bundleURL()
70
+ #endif
71
+ }
72
+ ```
73
+
74
+ 4. Add the Deployment key to `Info.plist`:
75
+
76
+ 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 `npx @swyng/cli app ls_deployment -n <AppName> -k (Show deployment key)` (the `-k` flag is necessary since keys aren't displayed by default) and copying the value of the `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.
77
+
78
+ ![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
79
+
80
+ 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.
81
+
82
+ *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)*
83
+
84
+ ```powershell
85
+ <key>CodePushDeploymentKey</key>
86
+ <string>deployment-key-here</string>
87
+ ```
88
+
89
+
90
+ ### HTTP exception domains configuration (iOS)
91
+
92
+ CodePush plugin makes HTTPS requests to the following domains:
93
+
94
+ - api.swyngpush.site
95
+
96
+ If you want to change the default HTTP security configuration for any of these domains, you have to define the [`NSAppTransportSecurity` (ATS)][ats] configuration inside your __Info.plist__ file:
97
+
98
+ ```xml
99
+ <plist version="1.0">
100
+ <dict>
101
+ <!-- ...other configs... -->
102
+
103
+ <key>NSAppTransportSecurity</key>
104
+ <dict>
105
+ <key>NSExceptionDomains</key>
106
+ <dict>
107
+ <key>api.swyngpush.site</key>
108
+ <dict><!-- read the ATS Apple Docs for available options --></dict>
109
+ </dict>
110
+ </dict>
111
+
112
+ <!-- ...other configs... -->
113
+ </dict>
114
+ </plist>
115
+ ```
116
+
117
+ Before doing anything, please [read the docs][ats] first.
118
+
119
+ [ats]: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33
120
+
121
+ ### Code Signing setup
122
+
123
+ 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/swyngpush/code-push/tree/v3.0.1/cli#code-signing).
124
+
125
+ 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:
126
+
127
+ ```xml
128
+ <plist version="1.0">
129
+ <dict>
130
+ <!-- ...other configs... -->
131
+
132
+ <key>CodePushPublicKey</key>
133
+ <string>-----BEGIN PUBLIC KEY-----
134
+ MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANkWYydPuyOumR/sn2agNBVDnzyRpM16NAUpYPGxNgjSEp0etkDNgzzdzyvyl+OsAGBYF3jCxYOXozum+uV5hQECAwEAAQ==
135
+ -----END PUBLIC KEY-----</string>
136
+
137
+ <!-- ...other configs... -->
138
+ </dict>
139
+ </plist>
140
+ ```
141
+
@@ -0,0 +1,121 @@
1
+ ## Windows Setup
2
+
3
+ Once you've acquired the CodePush plugin, you need to integrate it into the Visual Studio 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 Windows 0.63.6 version and above
6
+
7
+ #### Plugin Installation (Windows-npx)
8
+
9
+ Once the plugin has been downloaded, run `npx react-native autolink-windows` in your application's root directory to automatically add the CodePush c++ project to your application's windows solution file.
10
+
11
+ #### Plugin Configuration (Windows)
12
+
13
+ 1. Replace the following files located at `windows/<app name>` with those in the CodePushDemoAppCpp example app in this repo found at `Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp`:
14
+ 1. app.h
15
+ 2. app.cpp
16
+ 3. app.xaml
17
+
18
+ 2. In the above files, replace any occurance of `CodePushDemoAppCpp` with the name of your application
19
+
20
+ 3. Enter your application's app version and deployment key to the `configMap` object at the top of your app's `OnLaunched` method in `App.cpp`:
21
+
22
+ ```c++
23
+ ...
24
+ void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
25
+ {
26
+ winrt::Microsoft::CodePush::ReactNative::CodePushConfig::SetHost(Host());
27
+ auto configMap{ winrt::single_threaded_map<hstring, hstring>() };
28
+ configMap.Insert(L"appVersion", L"1.0.0");
29
+ configMap.Insert(L"deploymentKey", L"<app deployment key>");
30
+ winrt::Microsoft::CodePush::ReactNative::CodePushConfig::Init(configMap);
31
+ ...
32
+ }
33
+ ...
34
+ ```
35
+
36
+ #### Plugin Configuration (Windows) C#
37
+
38
+ 1. add name space `Microsoft.CodePush` to `App.xaml.cs`
39
+
40
+ 2. add app version and deployment key to `configMap` at the start of your app's `OnLaunched` method in `App.xaml.cs`.
41
+
42
+ ```c#
43
+ using Microsoft.CodePush;
44
+
45
+ ...
46
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
47
+ {
48
+ Microsoft.CodePush.ReactNative.CodePushConfig.SetHost(Host);
49
+ IDictionary<string, string> configMap = new Dictionary<string, string>();
50
+ configMap.Add("appVersion", "1.0.0");
51
+ configMap.Add("deploymentKey", "deployment key");
52
+ Microsoft.CodePush.ReactNative.CodePushConfig.Init(configMap);
53
+ ...
54
+ }
55
+ ...
56
+ ```
57
+
58
+
59
+ ### Plugin Installation and Configuration for React Native Windows lower than 0.60
60
+
61
+ #### Plugin Installation (Windows)
62
+
63
+ 1. Open the Visual Studio solution located at `windows-legacy\<AppName>\<AppName>.sln` within your app
64
+
65
+ 2. Right-click the solution node in the `Solution Explorer` window and select the `Add -> Existing Project...` menu item
66
+
67
+ ![Add Project](https://cloud.githubusercontent.com/assets/116461/14467164/ddf6312e-008e-11e6-8a10-44a8b44b5dfc.PNG)
68
+
69
+ 3. Browse to the `node_modules\react-native-code-push\windows` directory, select the `CodePush.csproj` file and click `OK`
70
+
71
+ 4. Back in the `Solution Explorer`, right-click the project node that is named after your app, and select the `Add -> Reference...` menu item
72
+
73
+ ![Add Reference](https://cloud.githubusercontent.com/assets/116461/14467154/d833bc98-008e-11e6-8e95-09864b1f05ef.PNG)
74
+
75
+ 5. Select the `Projects` tab on the left hand side, check the `CodePush` item and then click `OK`
76
+
77
+ ![Add Reference Dialog](https://cloud.githubusercontent.com/assets/116461/14467147/cb805b6e-008e-11e6-964f-f856c59b65af.PNG)
78
+
79
+ #### Plugin Configuration (Windows)
80
+
81
+ After installing the plugin, 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, update the `MainReactNativeHost.cs` file to use CodePush via the following changes:
82
+
83
+ ```c#
84
+ ...
85
+ // 1. Import the CodePush namespace
86
+ using CodePush.ReactNative;
87
+ ...
88
+ class MainReactNativeHost : ReactNativeHost
89
+ {
90
+ // 2. Declare a private instance variable for the CodePushModule instance.
91
+ private CodePushReactPackage codePushReactPackage;
92
+
93
+ // 3. Update the JavaScriptBundleFile property to initalize the CodePush runtime,
94
+ // specifying the right deployment key, then use it to return the bundle URL from
95
+ // CodePush instead of statically from the binary. If you don't already have your
96
+ // deployment key, you can run "npx @swyng/cli app ls_deployment -n <AppName> -k (Show deployment key)" to retrieve it.
97
+ protected override string JavaScriptBundleFile
98
+ {
99
+ get
100
+ {
101
+ codePushReactPackage = new CodePushReactPackage("deployment-key-here", this);
102
+ return codePushReactPackage.GetJavaScriptBundleFile();
103
+ }
104
+ }
105
+
106
+ // 4. Add the codePushReactPackage instance to the list of existing packages.
107
+ protected override List<IReactPackage> Packages
108
+ {
109
+ get
110
+ {
111
+ return new List<IReactPackage>
112
+ {
113
+ new MainReactPackage(),
114
+ ...
115
+ codePushReactPackage
116
+ };
117
+ }
118
+ }
119
+ ...
120
+ }
121
+ ```