Deploy => DeployDownloadOptions

Hi,

I’m tryin to add a progressbar to the download of a new package within the deploy scenario.
I didn’t get it work :-/

I tried to create a class that implements the interface, but I didn’t get it work to import the DeployDownloadOptions?

My code
import {Deploy, DeployDownloadOption} from ‘@ionic/cloud-angular’;

maybe anyone has already done sthg. like this?

thx
Meex

No one out there, who can help me :frowning:

Did you find this eventually?

Your link actually brought me into the right track to implement what I needed, so to give back here is the code I used :

this.deploy
   .download({
      onProgress: p => console.log('progress at ' + p + '%')
   })

Hope that helps!

In case someone could use my full code

this.deploy.check().then((snapshotAvailable: boolean) => {
    if (snapshotAvailable) {

        let alert = this.alertCtrl.create({
            title: 'There is an update to Awesome App',
            message: 'Do you want to update?',
            buttons: [{
                text: 'Cancel',
                handler: () => {
                    console.log('Cancel clicked');
                }
            }, {
                text: 'Update',
                handler: () => {

                    let updateMe = true;

                    let toast = this.toastCtrl.create({
                        message: 'Downloading .. 0%',
                        position: 'bottom',
                        showCloseButton: true,
                        closeButtonText: 'Cancel'
                    });

                    toast.onDidDismiss(() => {
                        updateMe = false;
                    });

                    toast.present();

                    // this.deploy.channel = 'production';
                    this.deploy
                        .download({
                            onProgress: p => {
                                toast.setMessage('Downloading .. ' + p + '%');
                                console.log('Downloading = ' + p + '%');
                            }
                        })
                        .then(() => {

                            if (updateMe) {
                                this.deploy
                                    .extract({
                                        onProgress: p => {
                                            toast.setMessage('Extracting .. ' + p + '%');
                                            console.log('Extracting = ' + p + '%');
                                        }
                                    })
                                    .then(() => {
                                        if (updateMe) {
                                            return this.deploy.load();
                                        }
                                    })
                                    .catch(() => toast.setMessage('Uhh ohh, network problem!'))
                            }

                        })
                        .catch(() => toast.setMessage('Uhh ohh, network problem!'))
                }
            }]
        });
        alert.present();
        // When snapshotAvailable is true, you can apply the snapshot

    }
});

Basically its

Check for Update --> Alert User --> Call Toast --> Download (update Toast with Download %) --> Extract (update Toast with Extract %) --> Load

Also a catch in case the connection breaks (Believe me, it happens!)

2 Likes

Thanks for this @dmastag - really helpful. It seems to be downloading/extracting/restarting OK, but I don’t see the changes I made in the latest snapshot showing up. Not sure if there’s something I’m missing.

Not sure, is the correct channel setup in ionic.io ?

Yeah. Turns out that I need to run “ionic build --prod” before uploading my snapshot. Since the app running on the device is built w/ aot I think the snapshot needs to match that or things get weird.

Also beware getting your app rejected by Apple if you have a prompt: Ionic Deploy iOS Apple App Store Rejection

Haha, yeah got that also.

Does deploy upload the AOT version of JS? I see the app got slow after deployed a new build.