cordova-plugin-code-push
cordova-plugin-code-push copied to clipboard
How to call onProgress function
Description
I'm using
window.codePush.checkForUpdate(onUpdateCheck, onError);
from docs
remote package
getsdownloaded
&installed
onProgress
callback do not executes onremotePackage.download(onPackageDownloaded, onError, onProgress);
Reproduction
function checkForUpdates(app){
codePush.checkForUpdate(function (remotePackage) {
if (!remotePackage) {
app.dialog.close();
} else {
navigator.notification.confirm(
"Please us to serve you more !",
// continue callback
function () {
console.log("inside continue callback");
var progressDialog = app.dialog.progress(
"TITLE",
"Setting you up ",
0
);
remotePackage.download(
//onPackageDownloaded
function (localPackage) {
app.dialog.close();
localPackage.install(
//onInstallSuccess
function () {
navigator.notification.alert(
"You are up to date with us!", // message
function () {}, // callback
"TITLE", // title
"close" // buttonName
);
},
//onError
function (err) {
console.log("err", err);
},
{
installMode: InstallMode.IMMEDIATE,
minimumBackgroundDuration: 120,
mandatoryInstallMode: InstallMode.IMMEDIATE,
}
);
},
//onError
function (error) {
console.log("err: ", error);
},
//onProgress DO NOT EXECUTES
function (downloadProgress) {
// DO NOT EXECUTES
console.log("inside download progress");
console.log(downloadProgress);
progressDialog.setProgress(
Math.trunc(
(downloadProgress.receivedBytes * 100) /
downloadProgress.totalBytes
)
);
progressDialog.setText(
"Setting you up " +
Math.trunc(
(downloadProgress.receivedBytes * 100) /
downloadProgress.totalBytes
) +
"%"
);
}
);
},
"Update available",
["Continue"]
);
}
}, null);
}
export { checkForUpdates };
Additional Information
- cordova-plugin-code-push version:
- List of installed plugins:
- code-push 3.0.1 "CodePushAcquisition"
- cordova-plugin-advanced-http 3.0.1 "Advanced HTTP plugin"
- cordova-plugin-code-push 1.13.1 "CodePush"
- cordova-plugin-device 2.0.3 "Device"
- cordova-plugin-dialogs 2.0.2 "Notification"
- cordova-plugin-file 6.0.2 "File"
- cordova-plugin-keyboard 1.2.0 "Keyboard"
- cordova-plugin-splashscreen 6.0.0 "Splashscreen"
- cordova-plugin-statusbar 2.4.3 "StatusBar"
- cordova-plugin-whitelist 1.3.4 "Whitelist"
- cordova-plugin-zip 3.1.0 "cordova-plugin-zip"
- Cordova version:
- 10.0.0
- iOS/Android/Windows version:
- android 9.0.0
- Does this reproduce on a debug build or release build?
- debug build
- Does this reproduce on a simulator, or only on a physical device?
- both
more on topic
At this time of posting, I'm sure, this is not a bug. I checked
codepush
in my other projects (platform - cordova).onprogress
callback works fine
- I've created seperate
codepush.js
file and linked it belowindex.html
works
Above code @Reproduction is taken from project where I use
Webpack
- so, i've made seperate
codepush.js
file. and exporting that. - also i've put
codePush.notifyApplicationReady();
call atdeviceReady
- new update downloads, installs, but
downloadProgress
do not execute even do notlogs
appreciate any guidance/article/resources
Thank You.
If you are using the latest because they use cordova-plugin-advanced-http plugin, the progress call will not be triggered as that plugin does not have a progress report. I switched it to use cordova-plugin-sslsupport
I'm getting the same problem with v1.13.1
-
downloadProgress
works on plaincordova
project 💯 - but, another
cordova
project which i've created using framework7 cli- which
bundles
UI usingwebpack
(where is something going wrong)
- which
If you are using the latest because they use cordova-plugin-advanced-http plugin, the progress call will not be triggered as that plugin does not have a progress report. I switched it to use cordova-plugin-sslsupport
can you show some relevant example/ refer any guide
I'm getting the same problem with v1.13.1
You can try v1.12.0, I downgrade to this version, the downloadProgress callback function working well.
Good luck for you.
https://www.npmjs.com/package/cordova-plugin-code-push/v/1.12.0
If you are using the latest because they use cordova-plugin-advanced-http plugin, the progress call will not be triggered as that plugin does not have a progress report. I switched it to use cordova-plugin-sslsupport
can you show some relevant example/ refer any guide
Hi, sorry for my...quite late response, but to use the other plugin 2 changes are needed. One in httpRequester.js and the other in remotePackage.js. I am giving you 2 screenshots that show the changes via a diff tool to help with making it easier to understand.


If you are using the latest because they use cordova-plugin-advanced-http plugin, the progress call will not be triggered as that plugin does not have a progress report. I switched it to use cordova-plugin-sslsupport
can you show some relevant example/ refer any guide
Hi, sorry for my...quite late response, but to use the other plugin 2 changes are needed. One in httpRequester.js and the other in remotePackage.js. I am giving you 2 screenshots that show the changes via a diff tool to help with making it easier to understand.
![]()
![]()
👍🏼