Ionic Cordova 代码推送更新总是 "pending"
Ionic Cordova Code Push Updates are always "pending"
描述
我将代码放在适当的位置进行无线更新,看起来代码确实推送了,但每次我 运行:
code-push deployment ls XXXXX
我得到:
有效:0%(XXX 中的 1)
总计:0(XXX 待定)
"pending" 永远不会切换到成功(但我确实看到了应用程序更新?)
复制
我正在使用 Ionic 应用程序 (+Redux) 已放入我的 app.component.ts:
platform.ready().then(() => { 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);
});
};
附加信息
cordova-plugin-code-push 版本: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" />
科尔多瓦版本:7.1.0
iOS/Android/Windows版本:全部
这是否会在调试版本或发布版本中重现?是
这是在模拟器上重现,还是只能在物理设备上重现?是
当您在代码推送 SDK 上调用 notifyApplicationReady()
失败时,可能会发生这种情况。应在应用程序启动附近的某处调用此方法。它有效地向 Code Push 报告更新成功。否则下次启动应用程序时,代码推送可能会触发回滚(取决于您部署更新的详细信息)。
https://github.com/Microsoft/cordova-plugin-code-push
notifyApplicationReady: Notifies the CodePush runtime that an installed update is considered successful. If you are manually checking for and installing updates (i.e. not using the sync method to handle it all for you), then this method MUST be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts.
无线更新现在正在运行。解决方案是进行重构并确保 sync
实际上是第一个被调用的东西。这样就可以在新构建starts-up.
时立即"stamp"构建成功
我认为问题在于我在此之前执行了一堆代码(包括一些 API 可能需要一两秒钟的调用)。
描述
我将代码放在适当的位置进行无线更新,看起来代码确实推送了,但每次我 运行:
code-push deployment ls XXXXX
我得到:
有效:0%(XXX 中的 1) 总计:0(XXX 待定)
"pending" 永远不会切换到成功(但我确实看到了应用程序更新?)
复制
我正在使用 Ionic 应用程序 (+Redux) 已放入我的 app.component.ts:
platform.ready().then(() => { 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);
});
};
附加信息 cordova-plugin-code-push 版本: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" />
科尔多瓦版本:7.1.0
iOS/Android/Windows版本:全部
这是否会在调试版本或发布版本中重现?是
这是在模拟器上重现,还是只能在物理设备上重现?是
当您在代码推送 SDK 上调用 notifyApplicationReady()
失败时,可能会发生这种情况。应在应用程序启动附近的某处调用此方法。它有效地向 Code Push 报告更新成功。否则下次启动应用程序时,代码推送可能会触发回滚(取决于您部署更新的详细信息)。
https://github.com/Microsoft/cordova-plugin-code-push
notifyApplicationReady: Notifies the CodePush runtime that an installed update is considered successful. If you are manually checking for and installing updates (i.e. not using the sync method to handle it all for you), then this method MUST be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts.
无线更新现在正在运行。解决方案是进行重构并确保 sync
实际上是第一个被调用的东西。这样就可以在新构建starts-up.
我认为问题在于我在此之前执行了一堆代码(包括一些 API 可能需要一两秒钟的调用)。