Hi
I want users decide if downloading the new version or not with prompt alert.
If I use method ‘auto’ or ‘background’ in prod mode, it will not ask it and just download.
And if I use method ‘none’ in android the deploy.check and download are working. But in IOS , it doesn’t work.
Anyone has same problem with me?
Thank you.
app.compoment.ts
import {Component, ElementRef, ViewChild} from “@angular/core”;
import {AlertController, Events, LoadingController, MenuController, Platform} from “ionic-angular”;
import {StatusBar} from “@ionic-native/status-bar”;
import {SplashScreen} from “@ionic-native/splash-screen”;
import {Device} from “@ionic-native/device”;
import {Firebase} from “@ionic-native/firebase”;
import {isNullOrUndefined} from “util”;
import {CacheService} from “ionic-cache”;
import {Pro as IonicPro} from “./ionic-native-pro-fixed”;
import {AppInfo, DeployInfo} from “@ionic-native/pro”;
import {NgZone} from “@angular/core”;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
public platformName;
public devMode = false;
public loader2;
constructor(platform: Platform,
public alertCtrl: AlertController,
public dataService: DataService,
private events: Events,
public loadingCtrl: LoadingController,
public menuCtrl: MenuController,
public sanitiser: DomSanitizer,
private firebase: Firebase,
splashscreen: SplashScreen,
device: Device,
statusBar: StatusBar,
public pro : IonicPro,
public ngZone: NgZone,
cache: CacheService) {
…
if (platform2.is('mobile') && !platform2.is('mobileweb')) {
me.ionicDeployCheck();
}
…
}
private ionicDeployCheck() {
let me = this;
me.pro.deploy.info().then((r:DeployInfo)=> {
console.log("deploy info: " + r.deploy_uuid);
console.log("deploy info: " + r.channel);
console.log("deploy info: " + r.binary_version);
me.dataService.get(“checkdeployLog”).then(rLog=>{
let temp = me.dataService.TodayDateToLongString() + “/” + r.channel + “/” + r.deploy_uuid;
if(rLog == null) {
rLog = [];
}
if(rLog.size > 10) {
rLog.shift();
}
rLog.push(temp);
me.dataService.set(“checkdeployLog”, rLog);
});
me.pro.deploy.check().then((res: any) => {
let msg = “update?”;
console.log(“Check result:”, res);
if (r.channel != ‘Production’) msg = "Channel Name: " + r.channel + " / " + msg;
if (res === ‘true’) {
let confirmUpdateAlert = this.alertCtrl.create({
title: “Update Found”,
message: msg,
buttons: [{
text: ‘Ignore’,
role: ‘cancel’
}, {
text: ‘Update’,
handler: () => {
me.ionicDeployDownload();
}
}]
});
confirmUpdateAlert.present().then(()=>{});
}
else {
console.log(‘Nothing to update’ + res);
}
}, (e: any) => {
console.log(“IonicdeployService error4” + e);
});
}).catch(e=>{
me.dataService.get("checkdeployLog").then(rLog=>{
let temp = me.dataService.TodayDateToLongString() + "/" + e;
if(rLog == null) {
rLog = [];
}
if(rLog.size > 10) {
rLog.shift();
}
rLog.push(temp);
me.dataService.set("checkdeployLog", rLog);
});
});
}
ionicDeployDownload() {
let me = this;
this.loader2 = this.loadingCtrl.create({
content: <div class="custom-spinner-container"> <div class="custom-spinner-box">Start Updating</div> </div>
,
showBackdrop: true
});
me.loader2.present();
// A new version is ready to download
me.pro.deploy.download().subscribe((res2: any) => {
console.log(“Check download:”, res2)
if (res2 === ‘true’ || res2 == ‘false’) {
// We can unzip the latest version
me.pro.deploy.extract().subscribe((res3: any) => {
console.log("Check extract:", res3)
if (res3 === 'true' || res3 == 'false' || res3 == 'done') {
me.loader2.dismiss();
// we're ready to load the new version
me.pro.deploy.redirect().then(() => {
console.log("redirect!");
}, (e: any) => {
console.log("IonicdeployService error1" + e);
})
} else {
// It's a progress update
console.log('Extract progress:', res3);
me.ngZone.run(() => {
me.loader2.setContent('Extract progress:' + res3 + '%');
});
}
}, (e: any) => {
console.log("IonicdeployService error2" + e);
me.loader2.dismiss();
})
} else {
// It's a progress update
console.log('Download progress:', res2);
me.ngZone.run(() => {
me.loader2.setContent('Downloading progress ' + res2 + '%');
});
}
}, (e: any) => {
console.log("IonicdeployService error3" + e);
me.loader2.dismiss();
})
}
config.xml
<plugin name="cordova-plugin-ionic" spec="^3.0.0">
<variable name="APP_ID" value="816c9d47" />
<variable name="CHANNEL_NAME" value="Production" />
<variable name="UPDATE_METHOD" value="none" />
<variable name="UPDATE_API" value="https://api.ionicjs.com" />
<variable name="MAX_STORE" value="2" />
</plugin>
=> ionic info
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.1
ionic (Ionic CLI) : 3.19.1
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.1.7
Cordova Platforms : ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 24.4.1
ios-deploy : 1.9.2
ios-sim : 5.0.11
Node : v7.10.0
npm : 5.6.0
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b
Environment Variables:
ANDROID_HOME : /usr/local/opt/android-sdk
Misc:
backend : pro
npm list --depth=0
springday-mobile@ /Users/amy/springday/mobile
├── @angular/animations@4.4.6
├── @angular/common@4.4.6
├── @angular/compiler@4.4.6
├── @angular/compiler-cli@4.4.6
├── @angular/core@4.4.6
├── @angular/forms@4.4.6
├── @angular/http@4.4.6
├── @angular/platform-browser@4.4.6
├── @angular/platform-browser-dynamic@4.4.6
├── @angular/platform-server@4.4.6
├── @ionic-native/calendar@4.5.2
├── @ionic-native/camera@4.5.2
├── @ionic-native/core@4.5.2
├── @ionic-native/deeplinks@4.5.2
├── @ionic-native/device@4.5.2
├── @ionic-native/file@4.5.2
├── @ionic-native/file-path@4.5.2
├── @ionic-native/firebase@4.5.2
├── @ionic-native/health@4.5.2
├── @ionic-native/in-app-browser@4.5.2
├── @ionic-native/market@4.5.2
├── @ionic-native/pro@4.5.2
├── @ionic-native/splash-screen@4.5.2
├── @ionic-native/status-bar@4.5.2
├── @ionic/app-scripts@3.1.7
├── @ionic/storage@2.1.3
├── chart.js@2.7.1
├── cordova-android@6.4.0
├── cordova-ios@4.5.4
├── cordova-plugin-add-swift-support@1.7.1
├── cordova-plugin-calendar@5.0.0
├── cordova-plugin-camera@4.0.1
├── cordova-plugin-compat@1.2.0
├── cordova-plugin-customurlscheme@4.3.0
├── cordova-plugin-device@2.0.1
├── cordova-plugin-file@6.0.1
├── cordova-plugin-filepath@1.1.0
├── cordova-plugin-firebase@0.1.25
├── cordova-plugin-health@1.0.3
├── cordova-plugin-inappbrowser@2.0.1
├── cordova-plugin-ionic@3.0.0
├── cordova-plugin-ionic-webview@1.1.16
├── cordova-plugin-ios-camera-permissions@1.2.0
├── cordova-plugin-market@1.2.0
├── cordova-plugin-splashscreen@5.0.1
├── cordova-plugin-statusbar@2.4.1
├── cordova-plugin-whitelist@1.3.3
├── cordova-sqlite-storage@2.2.0
├── ionic-angular@3.9.2
├── ionic-cache@2.0.5
├── ionic-plugin-keyboard@2.2.1
├── ionicons@3.0.0
├── moment@2.20.1
├── rxjs@5.5.6
├── sw-toolbox@3.6.0
├── typescript@2.6.2
├── webpack@3.10.0
└── zone.js@0.8.20