ios - Cordova 插件 CodePush - 重新启动 iOS 应用程序后更新丢失

标签 ios cordova visual-studio-app-center hockeyapp code-push

我在 Apple 商店有一个实时应用程序,它使用 Microsoft AppCenter CodePush 安装实时更新。 Cordova 插件:cordova-plugin-code-push .

当我发布 iOS 更新时,更新已正确安装,但下次我启动该应用程序时,更新就消失了!

没有任何日志表明更新已回滚,也没有其他错误日志。

  • 我的代码:
export function initCodePush() {
  return new Promise((resolve, reject) => {
    const codePush = getPlugin('codePush');
    console.log('{CodePush} - launching..');

    codePush.sync((syncStatus) => {
      // Called when the sync process moves from one stage to another in the overall update process
      // Possible values: 'UP_TO_DATE', 'UPDATE_INSTALLED', 'UPDATE_IGNORED', 'ERROR', 'IN_PROGRESS',
      // 'CHECKING_FOR_UPDATE', 'AWAITING_USER_ACTION', 'DOWNLOADING_PACKAGE', 'INSTALLING_UPDATE'.
      console.log(`{CodePush} - status: ${window.SyncStatus[syncStatus]}`);
    }, {
      updateDialog: false,
      installMode: window.InstallMode.ON_NEXT_RESTART,
      mandatoryInstallMode: window.InstallMode.IMMEDIATE,
    }, (downloadProgress) => {
      // capturing download progress and currently doing nothing.
      console.log(`{CodePush} - download progress: ${JSON.stringify(downloadProgress)}`);
    }, (err) => {
      console.error(err);
      reject(err);
    });

    // Since `codePush.sync()` is a blocking call, this `resolve()`
    // will only be called after one of the callbacks gets called.
    resolve();
  });
}
  • 日志:
19:07:53.591135-0400 {CodePush} - launching..
19:07:53.591303-0400 {CodePush} - status: CHECKING_FOR_UPDATE
19:07:53.781102-0400 [CodePush] Checking for update.
19:07:54.169450-0400 [CodePush] Reported status: {"status":0,"appVersion":"1.2","deploymentKey":"MY_PROD_KEY","previousLabelOrAppVersion":null,"previousDeploymentKey":null}
19:07:55.250285-0400 [CodePush] An update is available. {"appVersion":"1.2","deploymentKey":"MY_PROD_KEY","description":"PROD iOS - latest master with brown","downloadUrl":"https://codepushupdates.azureedge.net/storagev2/some-long-probably-sensitive-key","isMandatory":true,"label":"v16","packageHash":"along4ssh4sh","packageSize":5279914,"failedInstall":false}
19:07:55.250332-0400 {CodePush} - status: DOWNLOADING_PACKAGE
19:07:55.250407-0400 [CodePush] Downloading update
19:07:56.436079-0400 {CodePush} - download progress: {"receivedBytes":17996,"totalBytes":5279914}
19:07:56.446796-0400 {CodePush} - download progress: {"receivedBytes":79970,"totalBytes":5279914}
[...]
19:07:57.090707-0400 {CodePush} - download progress: {"receivedBytes":5160960,"totalBytes":5279914}
19:07:57.090832-0400 {CodePush} - download progress: {"receivedBytes":5279914,"totalBytes":5279914}
19:07:57.661513-0400 [CodePush] Package download success: {"deploymentKey":"MY_PROD_KEY","description":"PROD iOS - latest master with brown background","label":"v16","appVersion":"1.2","isMandatory":true,"packageHash":"long4ssp4ckageh4sh","isFirstRun":false,"failedInstall":false,"localPath":"cdvfile://localhost/library-nosync/codepush/download/update.zip"}
19:07:57.661754-0400 {CodePush} - status: INSTALLING_UPDATE
19:07:57.664468-0400 [CodePush] Installing update
19:08:00.312666-0400 [CodePush] Applying full update
19:08:00.463188-0400 [CodePush] Install succeeded.
19:08:00.463264-0400 {CodePush} - status: UPDATE_INSTALLED

// App restarted because mandatory update. Logs:
19:08:01.986773-0400 {CodePush} - launching..
19:08:01.986928-0400 {CodePush} - status: CHECKING_FOR_UPDATE
19:08:02.059582-0400 [CodePush] Checking for update.
19:08:02.219584-0400 [CodePush] Reported status: {"status":1,"label":"v16","appVersion":"1.2","deploymentKey":"MY_PROD_KEY","previousLabelOrAppVersion":"1.2","previousDeploymentKey":"MY_PROD_KEY"}
19:08:02.233273-0400 [CodePush] App is up to date.
19:08:02.233618-0400 {CodePush} - status: UP_TO_DATE
19:09:12.337888-0400 [CDVTimer][codepush] 3.816962ms

// Next App launch:
19:09:13.829947-0400 {CodePush} - launching..
19:09:13.831466-0400 {CodePush} - status: CHECKING_FOR_UPDATE
19:09:13.914494-0400 [CodePush] Checking for update.
19:09:14.372443-0400 [CodePush] App is up to date.
19:09:14.372535-0400 {CodePush} - status: UP_TO_DATE

状态是“UP_TO_DATE”..但它默默地将应用程序恢复为完全没有更新。报告中没有回滚。


我已经多次重现这个问题(~20)。我精通 CodePush CLI 和 AppCenter 仪表板。

注意:

  • 实时更新中唯一的变化是一行背景颜色(作为测试)

  • AppCenter CodePush 仪表板将安装计为成功。回滚计数为0!

  • 实时更新始终适用于 Android。应用重新启动后会保留更新。

  • 这个问题似乎是间歇性的(但始终如一)。几个小时前更新并没有丢失重新启动应用程序。

  • 使用 iOS 模拟器永远不会出现此问题


版本: - Cordova :v8.1.2 - Cordova -ios:v5.0.1 - iOS:12.3.1 - 发布构建 - 引擎:Ionic engine v4.0.0 (WKWebview)

最佳答案

确保在应用启动时调用 codepush.notifyApplicationReady。虽然 Codepush 文档说当你执行sync()时这不是必需的,但我注意到当我没有这样做时,一些与你所描述的行为类似的行为。

这可能不是您的问题,因为您说过没有回滚,但我将其留在这里,以防其他人发现这篇文章存在类似问题。

关于ios - Cordova 插件 CodePush - 重新启动 iOS 应用程序后更新丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57318219/

相关文章:

ios - 面向协议(protocol)编程和 Swift 类

objective-c - ^ 符号在 Objective-C 中是什么意思?

iOS 导航栏标题不在中心?

Firebase 云消息传递 (FCM) - HTTP V1 API 还是旧版 HTTP API?

ios - 点击通知后如何显示某个 View Controller 并发送数据?

cordova - 如何在cordova中安装已经记录在config.xml中的插件?

ios - 在 Phonegap 生成的应用商店中部署 .ipa 文件?

cordova - 为 Windows 7 构建 Cordova 应用程序

azure - AppCenter 结果为 TesPlan。 Azure 开发运营

react-native - 尽管存在 Podfile,AppCenter 似乎并未运行 pod install