Reputation: 4638
In order to serve updates faster to testers, I would like to use different CodePush options for Staging and Production. For example, in Staging distributions, I would like to remove minimumBackgroundDuration
from the config below
let codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.ON_NEXT_RESUME,
minimumBackgroundDuration: 60 * 10,
};
const CodePushApp = codePush(codePushOptions)(App);
What strategies are there to achieve this?
Upvotes: 1
Views: 961
Reputation: 3020
You can split your CodePush integration as Production and Staging with using
sync
function.
Check below example:
import React, { useEffect } from "react";
import codePush from "react-native-code-push";
const CodePushService = ({ stagingKey, productionKey, testUser }) => {
useEffect(() => {
codePush.notifyAppReady().then(() => {
if (testUser) {
codePush.sync({
deploymentKey: stagingKey,
installMode: codePush.InstallMode.IMMEDIATE,
updateDialog: {
appendReleaseDescription: true,
descriptionPrefix: "\n\nDeveloper Notes:\n\n",
},
});
} else {
codePush.sync({
deploymentKey: productionKey,
rollbackRetryOptions: {
delayInHours: 1, // default is 24
maxRetryAttempts: 3, // default is 1
},
});
}
});
}, [testUser, productionKey, stagingKey]);
return null;
};
export default codePush({ checkFrequency: codePush.CheckFrequency.MANUAL })(
CodePushService
);
You can use the above code like below:
import CodePushService from './CodePushService';
const App = () => {
return(
<>
<CodePushService
stagingKey="xxxxxxxxxxx"
productionKey="xxxxxxxxxx"
testUser={true} // make this part dynamic
/>
</>
);
}
Upvotes: 1