为了更快地为测试人员提供更新服务,我想使用不同的CodePush选项来进行测试和生产。例如,在准备发行版时,我希望从下面的配置中删除minimumBackgroundDuration
let codePushOptions = {
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.ON_NEXT_RESUME,
minimumBackgroundDuration: 60 * 10,
};
const CodePushApp = codePush(codePushOptions)(App);实现这一目标的战略是什么?
发布于 2022-04-26 02:47:15
您可以使用CodePush函数将您的CodePush集成拆分为生产和分阶段。
请查看下面的示例:
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
);您可以使用上述代码,如下所示:
import CodePushService from './CodePushService';
const App = () => {
return(
<>
<CodePushService
stagingKey="xxxxxxxxxxx"
productionKey="xxxxxxxxxx"
testUser={true} // make this part dynamic
/>
</>
);
}https://stackoverflow.com/questions/70638645
复制相似问题