首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于分期/Prod的不同CodePush选项

用于分期/Prod的不同CodePush选项
EN

Stack Overflow用户
提问于 2022-01-09 05:16:57
回答 1查看 296关注 0票数 0

为了更快地为测试人员提供更新服务,我想使用不同的CodePush选项来进行测试和生产。例如,在准备发行版时,我希望从下面的配置中删除minimumBackgroundDuration

代码语言:javascript
复制
let codePushOptions = {
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.ON_NEXT_RESUME,
  minimumBackgroundDuration: 60 * 10,
};
const CodePushApp = codePush(codePushOptions)(App);

实现这一目标的战略是什么?

EN

回答 1

Stack Overflow用户

发布于 2022-04-26 02:47:15

您可以使用CodePush函数将您的CodePush集成拆分为生产和分阶段。

请查看下面的示例:

代码语言:javascript
复制
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
);

您可以使用上述代码,如下所示:

代码语言:javascript
复制
import CodePushService from './CodePushService';

const App = () => {
  return(
    <>
      <CodePushService
        stagingKey="xxxxxxxxxxx"
        productionKey="xxxxxxxxxx"
        testUser={true} // make this part dynamic
      />
    </>
  );
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70638645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档