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!)