Ionic Deploy how to cancel download in progress

Is there currently any way to cancel/stop the $ionicDeploy.download() process? Our app has a fairly large amount of content and I’d like to display a progress bar along with a cancel button while the update is being downloaded to the app.

This cancel feature is required in the case where a user has a slow connection and the download takes a long time. We want to give users the option to back out in this situation.

So far I have not changed the download and extract code from what’s in the docs.

        // Download the updates
        $ionicDeploy.download().then(function() {
            // Extract the updates
            $ionicDeploy.extract().then(function() {
                // Load the updated version
                $ionicDeploy.load();
            }, function(error) {
                // Error extracting
            }, function(progress) {
                // Do something with the zip extraction progress
                $scope.extractionProgress = progress;
                console.log('Extraction Progress: ' + $scope.extractionProgress);
            });
        }, function(error) {
            // Error downloading the updates
        }, function(progress) {
            // Do something with the download progress
            $scope.downloadProgress = progress;
            console.log('Download Progress: ' + $scope.downloadProgress);
        });
1 Like

Looking at the code of the JS of ionic-platform-webclient and the JS and native code of the plugin I see no code that could be used to cancel a download. It just starts a download in the background and reports the background back to the callback.

But, I think it wouldn’t actually be too hard for a native developer to add this to the plugin. Probably a call to a function that sets a variable the download progress checks periodically and then just stops downloading. But of course this would need changes in all librariers (ionic-platform-webclient and plugin) - so better talk to the Ionic guys before implementing this, to find out if they actually want to merge this into their code.

Related:
Did you have any success displaying the process in a progress bar? I’m playing around with this right now, but somehow the values just don’t get updated.

D’oh, I could use this function now. Anybody built it yet?