为什么 CodePush 在安装较新的版本后显示有新更新可用?

问题描述 投票:0回答:1

我正在使用 AppCenter 为我的反应本机应用程序进行 OTA 更新,它在这里给了我一些奇怪的行为。 (在安卓上测试) 我将 codepush 更新推送到应用程序中心,目标版本是 1.0,标签为 v1。 然后,我将 versionCode 从 1 增加到 2,并将 versionName 从 1 更改为 1.0.1。 我确实推出了新版本。 现在版本中有一个版本为 1.0.1。我在我的 Android 上安装了此版本,但我发现有新的更新可用

这就是我检查更新的方式:

useEffect(() => {
    const checkForCodePushUpdate = () => {
      CodePush.checkForUpdate()
        .then(update => {
          console.log('update', update);
          if (update) {
            CodePush.sync(
              {
                updateDialog: {
                  title: 'New Update Available',
                  optionalUpdateMessage:
                    'Update available. Proceed with installation?',
                  optionalIgnoreButtonLabel: 'Later',
                  optionalInstallButtonLabel: 'Yes',
                  mandatoryContinueButtonLabel: 'Yes',
                  mandatoryUpdateMessage:
                    'Update available. Proceed with installation?',
                },
                installMode: CodePush.InstallMode.IMMEDIATE,
              },
              status => {
                if (status === CodePush.SyncStatus.DOWNLOADING_PACKAGE) {
                  setDownloading(true);
                }
                if (status !== CodePush.SyncStatus.DOWNLOADING_PACKAGE) {
                  setDownloading(false);
                }
              },
              progress => {
                const _progressPercent = Math.round(
                  (progress.receivedBytes / progress.totalBytes) * 100,
                );
                console.log('_app update progress percent', _progressPercent);
                setProgressPercent(_progressPercent);
              },
            );
          }
        })
        .catch(err => {
          console.log('app update error', err);
        });
    };
    AppState.addEventListener('change', state => {
      if (state === 'active') {
        checkForCodePushUpdate();
      }
    });
    checkForCodePushUpdate();
  }, []);

我已经用

包装了我的应用程序
export default codepush({checkFrequency: codepush.CheckFrequency.MANUAL})(App);

在信息内的

console.log("update", update)
中,标签是v1,但appVersion是1.0.1

为什么会发生这种情况? 我在这里尝试的是模仿之前发布更新后将应用程序发布到Playstore。从 Playstore 安装应用程序的用户在刚刚安装应用程序后不应该得到新的更新可用,特别是 Playstore 中的应用程序在发布 codepush 更新后确实已更新。

react-native visual-studio-app-center
1个回答
0
投票

原因是,当 codepush 更新针对 1.0 等版本时,它适用于 1.0.x 等所有补丁版本。 因此,如果您不想将其视为 1.0.1 中的更新,那么您的更新应该以 1.0.0 而不是 1.0 为目标

© www.soinside.com 2019 - 2024. All rights reserved.