Commit bce9a8a7 by Matteo

Aggiunta gestione aggiornamento app

parent d7956b0d
......@@ -22,6 +22,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient } from '@angular/common/http';
//import { Push } from '@ionic-native/push/ngx';
import { IonicStorageModule } from '@ionic/storage-angular';
import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
......@@ -37,6 +38,7 @@ export function createTranslateLoader(http: HttpClient) {
IonicStorageModule.forRoot(),
FormsModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
......@@ -55,6 +57,7 @@ export function createTranslateLoader(http: HttpClient) {
EmailComposer,
InAppBrowser,
SocialSharing,
AppVersion,
//Push,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
......
......@@ -13,6 +13,7 @@ import { environment } from '../../../environments/environment';
import { Struttura } from 'src/app/interface/struttura';
import { ParereResponse } from 'src/app/interface/parere-response';
import { EventsService } from 'src/app/service/events.service';
import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx';
@Component({
selector: 'app-home',
......@@ -27,9 +28,29 @@ export class HomePage {
public menuCtrl: MenuController,
private utilService: UtilService,
public translate: TranslateService,
public platform: Platform
public platform: Platform,
private appVersion: AppVersion
) {
this.caricaDati(true);
this.getVersion();
}
async getVersion()
{
if(UtilService.getVersion) return;
let version = await this.appVersion.getVersionNumber();
this.utilService.getVersion().subscribe((lastVersion: String)=>{
var numeri = lastVersion.split('.');
for(let i : number = 0; i < numeri.length; i++)
{
Number.parseInt(numeri[i]);
}
if(version != lastVersion)
{
this.utilService.presentAlert("Avviso", "", "E' presente una nuova versione dell'app sullo store ("+lastVersion+"), aggiorna la app", ["OK"]);
}
UtilService.getVersion = true;
});
}
caricaDati(startUp: boolean)
......
......@@ -123,8 +123,28 @@ export class UtilService {
public static strutturaSegreteria:Struttura;
public static pushRegistrationId:string;
public static redirectToNotifiche:boolean = false;
public static getVersion: boolean = false;
public startup :boolean = true;
getVersion()
{
var piattaforma = this.platform.is("android")?"android":"ios;"
var param = UtilService.encodeBody({app: environment.struttura, piattaforma: piattaforma});
return this.httpClient.post<String>(this.httpClientDataService.BASE_ADDRESS+'/intranet/ultimaVersione.do', param, this.httpClientDataService.httpOptions)
.pipe(
catchError(this.handleError),
tap( (res: String ) => {
if (res != null && res != "") {
return res;
}
else{
return null;
}
})
);
}
static setStruttura(id:number)
{
if(this.strutture.length > 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment