Reputation: 6347
I have a live App on the Apple store and it uses Microsoft AppCenter CodePush to install live updates. Cordova plugin: cordova-plugin-code-push.
When I publish an update for iOS the update is correctly installed but the next time I launch the app the update is gone!
There aren't any logs that indicate that the update has been rolled back and no other error logs.
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
The status is "UP_TO_DATE" ..but it silently reverted the App to NO UPDATES at all. No rollbacks in the report.
I have reproduced this issue numerous times (~20). I am proficient with CodePush CLI And AppCenter dashboards.
NOTE:
The only change in the live update is one single line for the background color (as a test)
AppCenter CodePush dashboard counts the installations as successful. The rollback count is 0!
Live updates always work on Android. Updates are kept after the App is relaunched.
This issue seems to be intermittent (but consistent). A couple of hours ago updates were not lost relaunching the app.
This issue never presents using the iOS Simulator
Versions:
- Cordova: v8.1.2
- cordova-ios: v5.0.1
- iOS: 12.3.1
- release build
- Engine: Ionic engine v4.0.0 (WKWebview)
Upvotes: 1
Views: 1571
Reputation: 884
Make sure you call codepush.notifyApplicationReady
when your app starts up. Although Codepush documentation says this isn't required when you do a sync(), I noticed some similar behavior to what you describe when I didn't have that.
This may not be your problem since you stated there were no rollbacks, but I'm leaving this here in case other people find this post with a similar problem.
Upvotes: 3
Reputation: 6347
This was not due to a CORS issue (even though for a while we saw some CORS errors in the logs - the AppCenter team may have fixed them in the mean time).
It's still not clear why live updates get lost after hard-closing the app (without any error logs).
Using this fork though the live udpates work and stick around on app re-launch.
Using the latest master of cordova-plugin-code-push instead it does not work. I'm still very confused as to why. In the forked plugin I only added some extra logs and it defaults to latest master of the plugin (but using it directly it does not work..). Verified this multiple times.
Upvotes: -1