Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

How to call onProgress function #652

Open
PRA1995SAG opened this issue Sep 21, 2020 · 7 comments
Open

How to call onProgress function #652

PRA1995SAG opened this issue Sep 21, 2020 · 7 comments

Comments

@PRA1995SAG
Copy link

PRA1995SAG commented Sep 21, 2020

Description

I'm using window.codePush.checkForUpdate(onUpdateCheck, onError); from docs

remote package gets downloaded & installed

onProgress callback do not executes on remotePackage.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 below index.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 at deviceReady
  • new update downloads, installs, but downloadProgress do not execute even do not logs

appreciate any guidance/article/resources

Thank You.
@pitAlex
Copy link

pitAlex commented Sep 28, 2020

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

@nguyendinhdoan
Copy link

I'm getting the same problem with v1.13.1

@PRA1995SAG
Copy link
Author

  • downloadProgress works on plain cordova project 💯
  • but, another cordova project which i've created using framework7 cli
    • which bundles UI using webpack (where is something going wrong)

@PRA1995SAG
Copy link
Author

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

@Coder7777
Copy link

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

@pitAlex
Copy link

pitAlex commented Apr 26, 2021

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.

Screen Shot 2021-04-26 at 10 50 07 PM

Screen Shot 2021-04-26 at 10 49 32 PM

@PRA1995SAG
Copy link
Author

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.

Screen Shot 2021-04-26 at 10 50 07 PM Screen Shot 2021-04-26 at 10 49 32 PM

👍🏼

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants