|
| 1 | +## @bravemobile/react-native-code-push |
| 2 | + |
| 3 | +Fork of `code-push-react-native` |
| 4 | + |
| 5 | +```bash |
| 6 | +npm install @bravemobile/react-native-code-push |
| 7 | +``` |
| 8 | + |
| 9 | +You'll have more flexibility and freedom in your deployment strategy. |
| 10 | +You can still use CodePush, but become independent of AppCenter's cloud infrastructure. |
| 11 | + |
| 12 | +### Self-host the update bundle file |
| 13 | + |
| 14 | +Specify the host and path using the `bundleHost` option. |
| 15 | + |
| 16 | +Upload the code-push bundle file to your server. The file name should be exactly same as the file on AppCenter. |
| 17 | + |
| 18 | +```javascript |
| 19 | +const codePushOptions = { |
| 20 | + bundlehost: 'https://cdn.yours.com/codepush/bundle/', |
| 21 | +}; |
| 22 | + |
| 23 | +export default codePush(codePushOptions)(MyApp); |
| 24 | +``` |
| 25 | + |
| 26 | +### Customize the update check behavior |
| 27 | + |
| 28 | +Specify a function to perform the update check using the `updateChecker` option. |
| 29 | + |
| 30 | +(The `bundleHost` option can be used in combination.) |
| 31 | + |
| 32 | +`fallbackToAppCenter` : If an error occurs during the execution of the updateChecker function, the original update check behavior is performed as a fallback. (default: true) |
| 33 | + |
| 34 | +```javascript |
| 35 | +const codePushOptions = { |
| 36 | + updateChecker: async (updateCheckRequest) => { |
| 37 | + // It's up to you to decide what to do. |
| 38 | + // However, you need to have a good understanding of Code Push's interface to configure your response. |
| 39 | + const { data: response } = await axios.get('https://your.api.com/update_check', { |
| 40 | + params: { app_version: updateCheckRequest.app_version } |
| 41 | + }); |
| 42 | + return response; |
| 43 | + }, |
| 44 | + fallbackToAppCenter: true, |
| 45 | +}; |
| 46 | + |
| 47 | +export default codePush(codePushOptions)(MyApp); |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | +## Original README.md is below. |
| 52 | + |
| 53 | +--- |
| 54 | + |
1 | 55 | [](http://microsoft.github.io/code-push/)
|
2 | 56 |
|
3 | 57 | #### [Sign up With App Center](https://appcenter.ms/signup?utm_source=CodePush&utm_medium=Azure) to use CodePush
|
@@ -246,44 +300,6 @@ If you would like to display an update confirmation dialog (an "active install")
|
246 | 300 |
|
247 | 301 | *NOTE: If you are using [Redux](http://redux.js.org) and [Redux Saga](https://redux-saga.js.org/), you can alternatively use the [react-native-code-push-saga](http://github.com/lostintangent/react-native-code-push-saga) module, which allows you to customize when `sync` is called in a perhaps simpler/more idiomatic way.*
|
248 | 302 |
|
249 |
| -You can self-host the update's file. Upload the file to your server exactly as you uploaded it to AppCenter. And specify the host and path using the `bundleHost` option. |
250 |
| - |
251 |
| -```javascript |
252 |
| -let codePushOptions = { |
253 |
| - checkFrequency: codePush.CheckFrequency.MANUAL, |
254 |
| - bundlehost: 'https://cdn.yours.com/codepush/bundle/', |
255 |
| -}; |
256 |
| -
|
257 |
| -let MyApp: () => React$Node = () => { |
258 |
| -} |
259 |
| -
|
260 |
| -MyApp = codePush(codePushOptions)(MyApp); |
261 |
| -``` |
262 |
| - |
263 |
| -You can customize the behavior by specifying a function to perform the update check instead. (The 'bundleHost' option can be used with it.) |
264 |
| - |
265 |
| -```javascript |
266 |
| -let codePushOptions = { |
267 |
| - checkFrequency: codePush.CheckFrequency.MANUAL, |
268 |
| - bundlehost: 'https://cdn.yours.com/codepush/bundle/', |
269 |
| - updateChecker: async (updateCheckRequest) => { |
270 |
| - // It's up to you to decide what to do. |
271 |
| - const { data: response } = await axios.get('https://your.api.com/update_check', { |
272 |
| - params: { app_version: updateCheckRequest.app_version } |
273 |
| - }); |
274 |
| - return response; |
275 |
| - }, |
276 |
| - // If an error occurs during the execution of the updateChecker function, the original update check behavior is performed as a fallback. (default: true) |
277 |
| - fallbackToAppCenter: true, |
278 |
| -}; |
279 |
| - |
280 |
| -let MyApp: () => React$Node = () => { |
281 |
| -} |
282 |
| - |
283 |
| -MyApp = codePush(codePushOptions)(MyApp); |
284 |
| -``` |
285 |
| -
|
286 |
| -
|
287 | 303 | ### Store Guideline Compliance
|
288 | 304 |
|
289 | 305 | Android Google Play and iOS App Store have corresponding guidelines that have rules you should be aware of before integrating the CodePush solution within your application.
|
|
0 commit comments