Skip to content

Commit bdb8c90

Browse files
committed
docs: add more details about install modes
1 parent 4819c88 commit bdb8c90

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,28 @@ By default, and this is recommended for production environments, CodePush will c
140140
If you would like your app to discover updates more quickly, you can also choose to sync up with the CodePush server every time the app resumes from the background.
141141

142142
```javascript
143-
withCodePush({ checkFrequency: CheckFrequency.ON_APP_RESUME })(MyApp);
143+
import withCodePush, { CheckFrequency, InstallMode } from '@appzung/react-native-code-push';
144+
145+
withCodePush({
146+
checkFrequency: CheckFrequency.ON_APP_RESUME,
147+
})(MyApp);
148+
```
149+
150+
For a more aggressive setup, you may choose to also install updates in the background or when the app resumes. Note that because the app would reload during update installation, the user might be slightly bothered unless you have a mechanism to come back to the exact same app state after restarting. You may minimize this discomfort using `minimumBackgroundDuration`.
151+
On Android in New Arch it is preferable to use ON_NEXT_RESUME instead of ON_NEXT_SUSPEND because it looks like React Native has a bug where network requests fail when React initializes in the background.
152+
153+
```javascript
154+
import { Platform } from 'react-native';
155+
import withCodePush, { CheckFrequency, InstallMode } from '@appzung/react-native-code-push';
156+
157+
withCodePush({
158+
checkFrequency: CheckFrequency.ON_APP_RESUME,
159+
installMode: Platform.OS === 'android' ? InstallMode.ON_NEXT_RESUME : InstallMode.ON_NEXT_SUSPEND,
160+
minimumBackgroundDuration: 60 * 5, // if the app is suspended more than 5 minutes, install the update. If the app is restarted (killed and restarted) it will also install the update.
161+
})(MyApp);
144162
```
145163

146-
Alternatively, if you want fine-grained control over when the check happens (like a button press or timer interval), eg. in a staging environment, you can call [`CodePush.sync()`](docs/api-js/functions/sync.md) at any time with your desired `SyncOptions`, and turn off CodePush's automatic checking by specifying a manual `checkFrequency`:
164+
Alternatively, if you want fine-grained control over when the check happens (like a button press or timer interval), e.g. in a staging environment, you can call [`CodePush.sync()`](docs/api-js/functions/sync.md) at any time with your desired `SyncOptions`, and turn off CodePush's automatic checking by specifying a manual `checkFrequency`:
147165

148166
```javascript
149167
import withCodePush, { CheckFrequency, InstallMode, sync } from '@appzung/react-native-code-push';

0 commit comments

Comments
 (0)