@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,229 @@
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 (iOS)
6
+
7
+ In order to accommodate as many developer preferences as possible, the CodePush plugin supports iOS installation via three mechanisms:
8
+
9
+ 1. [**RNPM**](#plugin-installation-ios---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.
10
+
11
+ 2. [**CocoaPods**](#plugin-installation-ios---cocoapods) - If you're building a native iOS app that is embedding React Native into it, or you simply prefer using [CocoaPods](https://cocoapods.org), then we recommend using the Podspec file that we ship as part of our plugin.
12
+
13
+ 3. [**"Manual"**](#plugin-installation-ios---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.
14
+
15
+ #### Plugin Installation (iOS - RNPM)
16
+
17
+ 1. As of v0.27 of React Native, `rnpm link` has already been merged into the React Native CLI. Simply run:
18
+ ```
19
+ react-native link react-native-code-push
20
+ ```
21
+
22
+ If your app uses a version of React Native that is lower than v0.27, run the following:
23
+ ```
24
+ rnpm link react-native-code-push
25
+ ```
26
+
27
+ *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. If you already have RNPM installed, make sure you have v1.9.0+ in order to benefit from this one step install.*
28
+
29
+ 2. 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.
30
+
31
+ And that's it! Isn't RNPM awesome? :)
32
+
33
+ #### Plugin Installation (iOS - CocoaPods)
34
+
35
+ 1. Add the ReactNative and CodePush plugin dependencies to your `Podfile`, pointing at the path where NPM installed it
36
+
37
+ ```
38
+ # React Native requirements
39
+ pod 'React', :path => '../node_modules/react-native', :subspecs => [
40
+ 'Core',
41
+ 'CxxBridge', # Include this for RN >= 0.47
42
+ 'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
43
+ 'RCTText',
44
+ 'RCTNetwork',
45
+ 'RCTWebSocket', # Needed for debugging
46
+ 'RCTAnimation', # Needed for FlatList and animations running on native UI thread
47
+ # Add any other subspecs you want to use in your project
48
+ ]
49
+ # Explicitly include Yoga if you are using RN >= 0.42.0
50
+ pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
51
+ pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
52
+ pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
53
+ pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
54
+
55
+ # CodePush plugin dependency
56
+ pod 'CodePush', :path => '../node_modules/react-native-code-push'
57
+ ```
58
+
59
+ *NOTE: The above path needs to be relative to your app's `Podfile`, so adjust it as necessary.*
60
+
61
+ *NOTE: `JWT` library should be >= version 3.0.x*
62
+
63
+ 2. Run `pod install`
64
+
65
+ *NOTE: The CodePush `.podspec` depends on the `React` pod, and so in order to ensure that it can correctly use the version of React Native that your app is built with, please make sure to define the `React` dependency in your app's `Podfile` as explained [here](https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#podfile).*
66
+
67
+ #### Plugin Installation (iOS - Manual)
68
+
69
+ 1. Open your app's Xcode project
70
+
71
+ 2. Find the `CodePush.xcodeproj` file within the `node_modules/react-native-code-push/ios` directory (or `node_modules/react-native-code-push` for <=`1.7.3-beta` installations) and drag it into the `Libraries` node in Xcode
72
+
73
+ ![Add CodePush to project](https://cloud.githubusercontent.com/assets/8598682/13368613/c5c21422-dca0-11e5-8594-c0ec5bde9d81.png)
74
+
75
+ 3. Select the project node in Xcode and select the "Build Phases" tab of your project configuration.
76
+
77
+ 4. Drag `libCodePush.a` from `Libraries/CodePush.xcodeproj/Products` into the "Link Binary With Libraries" section of your project's "Build Phases" configuration.
78
+
79
+ ![Link CodePush during build](https://cloud.githubusercontent.com/assets/516559/10322221/a75ea066-6c31-11e5-9d88-ff6f6a4d6968.png)
80
+
81
+ 5. Click the plus sign underneath the "Link Binary With Libraries" list and select the `libz.tbd` library underneath the `iOS 9.1` node.
82
+
83
+ ![Libz reference](https://cloud.githubusercontent.com/assets/116461/11605042/6f786e64-9aaa-11e5-8ca7-14b852f808b1.png)
84
+
85
+ *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
+
87
+
88
+ ### Plugin Configuration (iOS)
89
+
90
+ *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
+
92
+ Once your Xcode project has been setup to build/link the CodePush plugin, you need to configure your app to consult CodePush for the location of your JS bundle, since it is responsible for synchronizing it with updates that are released to the CodePush server. To do this, perform the following steps:
93
+
94
+ 1. Open up the `AppDelegate.m` file, and add an import statement for the CodePush headers:
95
+
96
+ ```objective-c
97
+ #import <CodePush/CodePush.h>
98
+ ```
99
+
100
+ For React Native 0.59 and above:
101
+
102
+ 2. Find the following line of code, which sets the source URL for bridge for production releases:
103
+
104
+ ```objective-c
105
+ return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
106
+ ```
107
+
108
+ 3. Replace it with this line:
109
+
110
+ ```objective-c
111
+ return [CodePush bundleURL];
112
+ ```
113
+
114
+ For React Native 0.58 and below:
115
+
116
+ 2. Find the following line of code, which loads your JS Bundle from the app binary for production releases:
117
+
118
+ ```objective-c
119
+ jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
120
+ ```
121
+
122
+ 3. Replace it with this line:
123
+
124
+ ```objective-c
125
+ jsCodeLocation = [CodePush bundleURL];
126
+ ```
127
+
128
+ 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.
129
+
130
+ *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*
131
+
132
+ 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
+
134
+ For React Native 0.59 and above:
135
+
136
+ ```objective-c
137
+ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
138
+ {
139
+ #if DEBUG
140
+ return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
141
+ #else
142
+ return [CodePush bundleURL];
143
+ #endif
144
+ }
145
+ ```
146
+
147
+ For React Native 0.49 - 0.58:
148
+
149
+ ```objective-c
150
+ NSURL *jsCodeLocation;
151
+
152
+ #ifdef DEBUG
153
+ jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
154
+ #else
155
+ jsCodeLocation = [CodePush bundleURL];
156
+ #endif
157
+ ```
158
+
159
+ For React Native 0.48 and below:
160
+
161
+ ```objective-c
162
+ NSURL *jsCodeLocation;
163
+
164
+ #ifdef DEBUG
165
+ jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
166
+ #else
167
+ jsCodeLocation = [CodePush bundleURL];
168
+ #endif
169
+ ```
170
+
171
+ 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.
172
+
173
+ ![Deployment list](https://cloud.githubusercontent.com/assets/116461/11601733/13011d5e-9a8a-11e5-9ce2-b100498ffb34.png)
174
+
175
+ 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.
176
+
177
+ ### HTTP exception domains configuration (iOS)
178
+
179
+ CodePush plugin makes HTTPS requests to the following domains:
180
+
181
+ - codepush.appzung.com
182
+ - release-package-files-eu.appzung.com
183
+
184
+ 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:
185
+
186
+ ```xml
187
+ <plist version="1.0">
188
+ <dict>
189
+ <!-- ...other configs... -->
190
+
191
+ <key>NSAppTransportSecurity</key>
192
+ <dict>
193
+ <key>NSExceptionDomains</key>
194
+ <dict>
195
+ <key>codepush.appzung.com</key>
196
+ <dict><!-- read the ATS Apple Docs for available options --></dict>
197
+ </dict>
198
+ </dict>
199
+
200
+ <!-- ...other configs... -->
201
+ </dict>
202
+ </plist>
203
+ ```
204
+
205
+ Before doing anything, please [read the docs][ats] first.
206
+
207
+ [ats]: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33
208
+
209
+ ### Code Signing setup
210
+
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).
212
+
213
+ 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
+
215
+ ```xml
216
+ <plist version="1.0">
217
+ <dict>
218
+ <!-- ...other configs... -->
219
+
220
+ <key>CodePushPublicKey</key>
221
+ <string>-----BEGIN PUBLIC KEY-----
222
+ MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANkWYydPuyOumR/sn2agNBVDnzyRpM16NAUpYPGxNgjSEp0etkDNgzzdzyvyl+OsAGBYF3jCxYOXozum+uV5hQECAwEAAQ==
223
+ -----END PUBLIC KEY-----</string>
224
+
225
+ <!-- ...other configs... -->
226
+ </dict>
227
+ </plist>
228
+ ```
229
+
@@ -0,0 +1,65 @@
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 (Windows)
6
+
7
+ 1. Open the Visual Studio solution located at `windows\<AppName>\<AppName>.sln` within your app
8
+
9
+ 2. Right-click the solution node in the `Solution Explorer` window and select the `Add -> Existing Project...` menu item
10
+
11
+ ![Add Project](https://cloud.githubusercontent.com/assets/116461/14467164/ddf6312e-008e-11e6-8a10-44a8b44b5dfc.PNG)
12
+
13
+ 3. Browse to the `node_modules\react-native-code-push\windows` directory, select the `CodePush.csproj` file and click `OK`
14
+
15
+ 4. Back in the `Solution Explorer`, right-click the project node that is named after your app, and select the `Add -> Reference...` menu item
16
+
17
+ ![Add Reference](https://cloud.githubusercontent.com/assets/116461/14467154/d833bc98-008e-11e6-8e95-09864b1f05ef.PNG)
18
+
19
+ 5. Select the `Projects` tab on the left hand side, check the `CodePush` item and then click `OK`
20
+
21
+ ![Add Reference Dialog](https://cloud.githubusercontent.com/assets/116461/14467147/cb805b6e-008e-11e6-964f-f856c59b65af.PNG)
22
+
23
+ ### Plugin Configuration (Windows)
24
+
25
+ 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:
26
+
27
+ ```c#
28
+ ...
29
+ // 1. Import the CodePush namespace
30
+ using CodePush.ReactNative;
31
+ ...
32
+ class MainReactNativeHost : ReactNativeHost
33
+ {
34
+ // 2. Declare a private instance variable for the CodePushModule instance.
35
+ private CodePushReactPackage codePushReactPackage;
36
+
37
+ // 3. Update the JavaScriptBundleFile property to initalize the CodePush runtime,
38
+ // specifying the right deployment key, then use it to return the bundle URL from
39
+ // CodePush instead of statically from the binary. If you don't already have your
40
+ // deployment key, you can run "code-push deployment ls <appName> -k" to retrieve it.
41
+ protected override string JavaScriptBundleFile
42
+ {
43
+ get
44
+ {
45
+ codePushReactPackage = new CodePushReactPackage("deployment-key-here", this);
46
+ return codePushReactPackage.GetJavaScriptBundleFile();
47
+ }
48
+ }
49
+
50
+ // 4. Add the codePushReactPackage instance to the list of existing packages.
51
+ protected override List<IReactPackage> Packages
52
+ {
53
+ get
54
+ {
55
+ return new List<IReactPackage>
56
+ {
57
+ new MainReactPackage(),
58
+ ...
59
+ codePushReactPackage
60
+ };
61
+ }
62
+ }
63
+ ...
64
+ }
65
+ ```
package/gulpfile.js ADDED
@@ -0,0 +1,302 @@
1
+ var del = require("del");
2
+ var gulp = require("gulp");
3
+ var path = require("path");
4
+ var child_process = require("child_process");
5
+ var Q = require("q");
6
+ var runSequence = require("run-sequence");
7
+
8
+ var testPath = "./test";
9
+ var binPath = "./bin";
10
+ var tsFiles = "/**/*.ts";
11
+
12
+ var iOSSimulatorProcessName = "Simulator";
13
+ var emulatorReadyCheckDelay = 30 * 1000;
14
+ var emulatorMaxReadyAttempts = 5;
15
+
16
+ /* This message is appended to the compiled JS files to avoid contributions to the compiled sources.*/
17
+ var compiledSourceWarningMessage = "\n \
18
+ /******************************************************************************************** \n \
19
+ THIS FILE HAS BEEN COMPILED FROM TYPESCRIPT SOURCES. \n \
20
+ PLEASE DO NOT MODIFY THIS FILE AS YOU WILL LOSE YOUR CHANGES WHEN RECOMPILING. \n \
21
+ ALSO, PLEASE DO NOT SUBMIT PULL REQUESTS WITH CHANGES TO THIS FILE. \n \
22
+ INSTEAD, EDIT THE TYPESCRIPT SOURCES UNDER THE WWW FOLDER. \n \
23
+ FOR MORE INFORMATION, PLEASE SEE CONTRIBUTING.md. \n \
24
+ *********************************************************************************************/ \n\n\n";
25
+
26
+ /* TypeScript compilation parameters */
27
+ var tsCompileOptions = {
28
+ "noImplicitAny": true,
29
+ "noEmitOnError": true,
30
+ "target": "ES5",
31
+ "module": "commonjs",
32
+ "sourceMap": false,
33
+ "sortOutput": true,
34
+ "removeComments": true
35
+ };
36
+
37
+ function spawnCommand(command, args, callback, silent, detached) {
38
+ var options = { maxBuffer: 1024 * 1024 };
39
+ if (detached) {
40
+ options.detached = true;
41
+ options.stdio = ["ignore"];
42
+ }
43
+
44
+ var spawnProcess = child_process.spawn(command, args, options);
45
+
46
+ if (!silent) spawnProcess.stdout.pipe(process.stdout);
47
+ if (!silent) spawnProcess.stderr.pipe(process.stderr);
48
+
49
+ if (!detached) {
50
+ spawnProcess.on('exit', function (code) {
51
+ callback && callback(code === 0 ? undefined : "Error code: " + code);
52
+ });
53
+ }
54
+
55
+ return spawnProcess;
56
+ };
57
+
58
+ function execCommand(command, args, callback, silent) {
59
+ var execProcess = child_process.exec(command + " " + args.join(" "), { maxBuffer: 1024 * 1024 });
60
+
61
+ if (!silent) execProcess.stdout.pipe(process.stdout);
62
+ if (!silent) execProcess.stderr.pipe(process.stderr);
63
+
64
+ execProcess.on('error', function (error) {
65
+ callback && callback(error);
66
+ })
67
+
68
+ execProcess.on('exit', function (code) {
69
+ callback && callback(code === 0 ? undefined : "Error code: " + code);
70
+ });
71
+
72
+ return execProcess;
73
+ };
74
+
75
+ function runTests(callback, options) {
76
+ var command = "mocha";
77
+ var args = ["./bin/test"];
78
+
79
+ // pass arguments supplied by test tasks
80
+ if (options.android) args.push("--android");
81
+ if (options.ios) args.push("--ios");
82
+ if (options.setup) args.push("--setup");
83
+
84
+ // pass arguments from command line
85
+ // the fourth argument is the first argument after the task name
86
+ for (var i = 3; i < process.argv.length; i++) {
87
+ if (process.argv[i] === "--report") {
88
+ // Set up the mocha junit reporter.
89
+ args.push("--reporter");
90
+ args.push("mocha-junit-reporter");
91
+
92
+ // Set the mocha reporter to the correct output file.
93
+ args.push("--reporter-options");
94
+ var filename = "./test-results.xml";
95
+ if (options.android && !options.ios) filename = "./test-android.xml";
96
+ else if (options.ios && !options.android) filename = "./test-ios.xml";
97
+ args.push("mochaFile=" + filename);
98
+ // Delete previous test result file so TFS doesn't read the old file if the tests exit before saving
99
+ del(filename);
100
+ } else args.push(process.argv[i]);
101
+ }
102
+
103
+ execCommand(command, args, callback);
104
+ }
105
+
106
+ gulp.task("compile", function (callback) {
107
+ runSequence("compile-test", callback);
108
+ });
109
+
110
+ gulp.task("compile-test", function () {
111
+ var ts = require("gulp-typescript");
112
+ var insert = require("gulp-insert");
113
+
114
+ return gulp.src([testPath + tsFiles])
115
+ .pipe(ts(tsCompileOptions))
116
+ .pipe(insert.prepend(compiledSourceWarningMessage))
117
+ .pipe(gulp.dest(path.join(binPath, testPath)));
118
+ });
119
+
120
+ gulp.task("tslint", function () {
121
+ var tslint = require('gulp-tslint');
122
+
123
+ // Configuration options adapted from TypeScript project:
124
+ // https://github.com/Microsoft/TypeScript/blob/master/tslint.json
125
+
126
+ var config = {
127
+ "rules": {
128
+ "class-name": true,
129
+ "comment-format": [true,
130
+ "check-space"
131
+ ],
132
+ "indent": [true,
133
+ "spaces"
134
+ ],
135
+ "one-line": [true,
136
+ "check-open-brace"
137
+ ],
138
+ "no-unreachable": true,
139
+ "no-unused-variable": true,
140
+ "no-use-before-declare": true,
141
+ "quotemark": [true,
142
+ "double"
143
+ ],
144
+ "semicolon": true,
145
+ "whitespace": [true,
146
+ "check-branch",
147
+ "check-operator",
148
+ "check-separator",
149
+ "check-type"
150
+ ],
151
+ "typedef-whitespace": [true, {
152
+ "call-signature": "nospace",
153
+ "index-signature": "nospace",
154
+ "parameter": "nospace",
155
+ "property-declaration": "nospace",
156
+ "variable-declaration": "nospace"
157
+ }]
158
+ }
159
+ }
160
+
161
+ return gulp.src([testPath + tsFiles, "!" + testPath + "/typings/*"])
162
+ .pipe(tslint({ configuration: config }))
163
+ .pipe(tslint.report("verbose"));
164
+ });
165
+
166
+ gulp.task("clean", function () {
167
+ return del([binPath + "/**"], { force: true });
168
+ });
169
+
170
+ gulp.task("default", function (callback) {
171
+ runSequence("clean", "compile", "tslint", callback);
172
+ });
173
+
174
+ ////////////////////////////////////////////////////////////////////////
175
+ // Test Tasks //////////////////////////////////////////////////////////
176
+
177
+ ////////////////////////////////////////////////////////////////////////
178
+ // Standalone Tasks
179
+ //
180
+ // Run the tests without setting up the test projects.
181
+ // Don't run these without running a setup task first!
182
+
183
+ // Run on Android standalone
184
+ gulp.task("test-run-android", function (callback) {
185
+ var options = {
186
+ android: true
187
+ };
188
+
189
+ runTests(callback, options);
190
+ });
191
+
192
+ // Run on iOS standalone
193
+ gulp.task("test-run-ios", function (callback) {
194
+ var options = {
195
+ ios: true,
196
+ ui: true,
197
+ };
198
+
199
+ runTests(callback, options);
200
+ });
201
+
202
+ ////////////////////////////////////////////////////////////////////////
203
+ // Setup Tasks
204
+ //
205
+ // Sets up the test project directories that the tests use and starts emulators.
206
+ // Must run before running a standalone suite of tests!
207
+
208
+ // Sets up the test projects and starts an Android emulator
209
+ gulp.task("test-setup-android", function (callback) {
210
+ var options = {
211
+ setup: true,
212
+ android: true
213
+ };
214
+
215
+ runTests(callback, options);
216
+ });
217
+
218
+ // Sets up the test projects and starts an iOS emulator
219
+ gulp.task("test-setup-ios", function (callback) {
220
+ var options = {
221
+ setup: true,
222
+ ios: true
223
+ };
224
+
225
+ runTests(callback, options);
226
+ });
227
+
228
+ // Sets up the test projects and starts both emulators
229
+ gulp.task("test-setup-both", function (callback) {
230
+ var options = {
231
+ setup: true,
232
+ android: true,
233
+ ios: true
234
+ };
235
+
236
+ runTests(callback, options);
237
+ });
238
+
239
+ // Builds, sets up test projects, and starts the Android emulator
240
+ gulp.task("test-setup-build-android", function (callback) {
241
+ runSequence("default", "test-setup-android", callback);
242
+ });
243
+
244
+ // Builds, sets up test projects, and starts the iOS emulator
245
+ gulp.task("test-setup-build-ios", function (callback) {
246
+ runSequence("default", "test-setup-ios", callback);
247
+ });
248
+
249
+ // Builds, sets up test projects, and starts both emulators
250
+ gulp.task("test-setup-build-both", function (callback) {
251
+ runSequence("default", "test-setup-both", callback);
252
+ });
253
+
254
+ ////////////////////////////////////////////////////////////////////////
255
+ // Fast Test Tasks
256
+ //
257
+ // Runs tests but doesn't build or start emulators.
258
+
259
+ // Run on Android fast
260
+ gulp.task("test-android-fast", ["test-setup-android"], function (callback) {
261
+ runSequence("test-run-android", callback);
262
+ });
263
+
264
+ // Run on iOS fast
265
+ gulp.task("test-ios-fast", ["test-setup-ios"], function (callback) {
266
+ runSequence("test-run-ios", callback);
267
+ });
268
+
269
+ ////////////////////////////////////////////////////////////////////////
270
+ // Fast Composition Test Tasks
271
+ //
272
+ // Run tests but doesn't build or start emulators.
273
+
274
+ // Run on iOS fast
275
+ gulp.task("test-fast", ["test-setup-both"], function (callback) {
276
+ runSequence("test-run-android", "test-run-ios", callback);
277
+ });
278
+
279
+ ////////////////////////////////////////////////////////////////////////
280
+ // Test Tasks
281
+ //
282
+ // Run tests, build, and start emulators.
283
+
284
+ // Run on Android
285
+ gulp.task("test-android", ["test-setup-build-android"], function (callback) {
286
+ runSequence("test-run-android", callback);
287
+ });
288
+
289
+ // Run on iOS
290
+ gulp.task("test-ios", ["test-setup-build-ios"], function (callback) {
291
+ runSequence("test-run-ios", callback);
292
+ });
293
+
294
+ ////////////////////////////////////////////////////////////////////////
295
+ // Composition Test Tasks
296
+ //
297
+ // Run tests, build, and start emulators.
298
+
299
+ // Run on Android and iOS
300
+ gulp.task("test", ["test-setup-build-both"], function (callback) {
301
+ runSequence("test-run-android", "test-run-ios", callback);
302
+ });
@@ -0,0 +1,34 @@
1
+ //
2
+ // MF_Base64Additions.h
3
+ // Base64 -- RFC 4648 compatible implementation
4
+ // see http://www.ietf.org/rfc/rfc4648.txt for more details
5
+ //
6
+ // Designed to be compiled with Automatic Reference Counting
7
+ //
8
+ // Created by Dave Poirier on 2012-06-14.
9
+ // Public Domain
10
+ // Hosted at https://github.com/ekscrypto/Base64
11
+ //
12
+
13
+ #import <Foundation/Foundation.h>
14
+
15
+ @interface NSString (Base64Addition)
16
+ +(NSString *)stringFromBase64String:(NSString *)base64String;
17
+ +(NSString *)stringFromBase64UrlEncodedString:(NSString *)base64UrlEncodedString;
18
+ -(NSString *)base64String;
19
+ -(NSString *)base64UrlEncodedString;
20
+ @end
21
+
22
+ @interface NSData (Base64Addition)
23
+ +(NSData *)dataWithBase64String:(NSString *)base64String;
24
+ +(NSData *)dataWithBase64UrlEncodedString:(NSString *)base64UrlEncodedString;
25
+ -(NSString *)base64String;
26
+ -(NSString *)base64UrlEncodedString;
27
+ @end
28
+
29
+ @interface MF_Base64Codec : NSObject
30
+ +(NSData *)dataFromBase64String:(NSString *)base64String;
31
+ +(NSString *)base64StringFromData:(NSData *)data;
32
+ +(NSString *)base64UrlEncodedStringFromBase64String:(NSString *)base64String;
33
+ +(NSString *)base64StringFromBase64UrlEncodedString:(NSString *)base64UrlEncodedString;
34
+ @end