|
| 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
|
|
0 commit comments