Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
爱奥尼亚Cordova代码推送更新始终为;待决“; 描述_Cordova_Ionic Framework_Code Push - Fatal编程技术网

爱奥尼亚Cordova代码推送更新始终为;待决“; 描述

爱奥尼亚Cordova代码推送更新始终为;待决“; 描述,cordova,ionic-framework,code-push,Cordova,Ionic Framework,Code Push,我将代码放在适当的位置进行无线更新,代码似乎确实在推送,但每次运行时: 代码推送部署ls XXXXX 我得到: 有效:0%(XXX中的1个) 总数:0(XXX待定) “挂起”从未切换到成功(但我确实看到应用程序更新?) 繁殖 我正在使用Ionic应用程序(+Redux),并已在我的app.component.ts中放入: platform.ready()。然后(()=>{this.ngRedux.dispatch(update());}) update()位于另一个文件中: const chan

我将代码放在适当的位置进行无线更新,代码似乎确实在推送,但每次运行时:
代码推送部署ls XXXXX

我得到:

有效:0%(XXX中的1个) 总数:0(XXX待定)

“挂起”从未切换到成功(但我确实看到应用程序更新?)

繁殖 我正在使用Ionic应用程序(+Redux),并已在我的app.component.ts中放入:

platform.ready()。然后(()=>{this.ngRedux.dispatch(update());})
update()位于另一个文件中:

const changeUpdateStatus = status => ({
  type: 'UPDATE_STATUS',
  payload: status
});
export const update = () => dispatch => {
  dispatch(changeUpdateStatus('INIT'));

  let sync = () => {
    let codePush = (<any>window).codePush;
    let SyncStatus = (<any>window).SyncStatus;

    if(!codePush){
      throw new Error('Code push not installed');
    };
    const keys = {
      'iOS': env.codePushKeys.ios,
      'Android': env.codePushKeys.android
    };
    const deploymentKey = keys[(<any>window).device.platform];
    console.log('Trying to sync code push using key: ', deploymentKey);

    codePush.sync(
      (status) => {
        console.log('status:', status);
        switch (status) {
          case SyncStatus.UPDATE_INSTALLED:
            dispatch(changeUpdateStatus('DONE'));
          break;
          case SyncStatus.CHECKING_FOR_UPDATE:
            dispatch(changeUpdateStatus('CHECKING'));
          break;
          case SyncStatus.DOWNLOADING_PACKAGE:
            dispatch(changeUpdateStatus('DOWNLOADING'));
          break;
          case SyncStatus.INSTALLING_UPDATE:
            dispatch(changeUpdateStatus('INSTALLING'));
          break;
          default: //ERROR, UP_TO_DATE
            dispatch(changeUpdateStatus('DONE'));
          break;
        }
      },
      {
        deploymentKey,
        installMode: (<any>window).InstallMode.IMMEDIATE,
        mandatoryInstallMode: (<any>window).InstallMode.IMMEDIATE
      },
      (downloadProgress) => {
        // TODO: Add progress to state.
        if (downloadProgress) {
            console.log("Downloading " + downloadProgress.receivedBytes + " of " + downloadProgress.totalBytes);
        }
      }
    );
  }  
  sync() && onEvent("resume").then(sync).catch( (e) => {
    dispatch(changeUpdateStatus('DONE'));
    analytics.logError(e);
  });
};
const changeUpdateStatus=status=>({
键入:“更新_状态”,
有效载荷:状态
});
导出常量更新=()=>dispatch=>{
调度(changeUpdateStatus('INIT'));
让同步=()=>{
让codePush=(窗口).codePush;
让SyncStatus=(窗口).SyncStatus;
如果(!codePush){
抛出新错误(“未安装代码推送”);
};
常量键={
“iOS”:env.codePushKeys.iOS,
“Android”:env.codePushKeys.Android
};
const deploymentKey=keys[(window.device.platform];
log('尝试使用键:'同步代码推送,deploymentKey');
codePush.sync(
(状态)=>{
console.log('状态:',状态);
开关(状态){
案例SyncStatus.UPDATE\u已安装:
调度(变更更新状态(“完成”);
打破
案例SyncStatus.CHECKING_以获取_更新:
调度(changeUpdateStatus(“检查”);
打破
case SyncStatus.DOWNLOADING_包:
发送(changeUpdateStatus(“下载”);
打破
案例SyncStatus.INSTALLING\u更新:
派遣(changeUpdateStatus(“安装”);
打破
默认值://错误,最新
调度(变更更新状态(“完成”);
打破
}
},
{
部署键,
installMode:(窗口)。installMode.Instant,
mandatoryInstallMode:(窗口).InstallMode.IMMEDIATE
},
(下载进度)=>{
//TODO:将进度添加到状态。
如果(下载进度){
log(“下载”+downloadProgress.receivedBytes+“+downloadProgress.totalBytes”中的“+downloadProgress.receivedBytes+”);
}
}
);
}  
sync()&&onEvent(“resume”)。然后(sync)。catch((e)=>{
调度(变更更新状态(“完成”);
分析。日志错误(e);
});
};
补充资料 cordova插件代码推送版本:1.11.0

已安装插件的列表:

    <plugin name="cordova-plugin-camera" spec="^3.0.0" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-device" spec="^1.1.7" />
    <plugin name="cordova-plugin-ionic-webview" spec="^1.1.16" />
    <plugin name="cordova-plugin-contacts" spec="^3.0.0" />
    <plugin name="cordova-plugin-camera-preview" spec="^0.9.0" />
    <plugin name="cordova-plugin-file-transfer" spec="^1.7.0" />
    <plugin name="cordova-plugin-background-upload" spec="^1.0.6" />
    <plugin name="cordova-plugin-media-capture" spec="^3.0.0" />
    <plugin name="cordova-sms-plugin" spec="^0.1.11" />
    <plugin name="cordova-plugin-statusbar" spec="^2.4.1" />
    <plugin name="cordova-plugin-code-push" spec="~1.11.0" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="phonegap-plugin-push" spec="^2.1.2">
        <variable name="FCM_VERSION" value="11.0.1" />
    </plugin>
    <plugin name="cordova-android-support-gradle-release" spec="^1.2.0">
        <variable name="ANDROID_SUPPORT_VERSION" value="26.+" />
    </plugin>
    <plugin name="cordova-plugin-globalization" spec="^1.0.7" />
    <plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />

Cordova版本:7.1.0

iOS/Android/Windows版本:全部

这会在调试版本或发布版本中重现吗?对


这是在模拟器上重现,还是仅在物理设备上重现?是

如果无法在代码推送SDK上调用
notifyApplicationReady()
,则可能发生这种情况。应该在应用程序启动时调用此方法。它有效地向代码推送报告更新成功。否则,下次启动应用程序时,代码推送可能会触发回滚(取决于您如何部署更新的详细信息)

notifyApplicationReady:通知CodePush运行时已安装的更新被视为成功。如果您正在手动检查和安装更新(即不使用sync方法为您处理所有更新),则必须调用此方法;否则,CodePush会将更新视为失败,并在应用程序下次重新启动时回滚到以前的版本


无线更新正在运行。解决方案是进行重构,并确保
sync
实际上是被调用的第一件事。这样,当新构建启动时,它可以立即将构建“标记”为成功


我相信问题在于在此之前我执行了大量代码(包括一些可能需要一两秒钟的API调用)。

感谢您回复文档。我不需要调用notifyApplicationReady()“如果您正在使用同步功能,并在应用程序启动时执行更新检查,则无需手动调用notifyApplicationReady,因为同步将为您调用它。这种行为之所以存在,是因为假设在应用程序中调用sync的点代表了成功启动的良好近似值。”