diff --git a/Mohem/config.xml b/Mohem/config.xml index 55d5ce3c..866ace59 100644 --- a/Mohem/config.xml +++ b/Mohem/config.xml @@ -15,11 +15,14 @@ - + + + + diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index ee77b995..0a08df19 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -88,9 +88,9 @@ export class AppComponent implements OnInit, AfterViewInit { console.log("platform.ready") this.pushService.startReceiving(); setTimeout(() => { - + console.log(" in setTimeout startReceiving"); this.getLastLoginInfo(); - },5000); + },4000); } subscribeEvents() { @@ -202,8 +202,18 @@ export class AppComponent implements OnInit, AfterViewInit { } getLastLoginInfo(){ - this.deviceToken= localStorage.getItem('devicyeToken'); - console.log("let deviceToken app" + this.deviceToken); + + + console.log(" getLastLoginInfo"); + console.log("get method :"+this.cs.getDeviceToken()); + this.deviceToken= this.cs.getDeviceToken(); + //this.cs.sharedService.getSharedData("new-device-token",false);// localStorage.getItem('devicyeToken'); + console.log("let deviceToken app" + this.cs.sharedService.getSharedData("new-device-token",false)); + console.log("localStorage.getItem app" + localStorage.getItem('devicyeToken')); + console.log("sheard DEVICE_TOKEN" + this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false)); + + + if (this.deviceToken) { console.log('login enabled first time: ' + this.deviceToken); @@ -236,8 +246,10 @@ export class AppComponent implements OnInit, AfterViewInit { ); this.user = true; this.events.publish('user', this.user); + setTimeout(() => { + this.splashScreen.hide(); + },3000); - this.splashScreen.hide(); if(this.logoutFlage){ this.cs.openLogin(); @@ -247,7 +259,11 @@ export class AppComponent implements OnInit, AfterViewInit { else{ this.user = false; this.events.publish('user', this.user); - this.splashScreen.hide(); + + setTimeout(() => { + this.splashScreen.hide(); + },3000); + if(this.logoutFlage){ this.cs.openLogin(); diff --git a/Mohem/src/app/hmg-common/services/common/common.service.ts b/Mohem/src/app/hmg-common/services/common/common.service.ts index 660e0b80..08163c91 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -80,6 +80,7 @@ export class CommonService { private loadingProgress: any; public updateImage:boolean=false; public setUpdateImg:any; + DT: any; constructor( public nav: NavController, public router: Router, @@ -1412,6 +1413,13 @@ public getMonthNameAr(value: number): string { return objImg; } - + setDeviceToken(deviceToken){ + this.DT=deviceToken; + } + + getDeviceToken(){ + return this.DT; + } + } diff --git a/Mohem/src/app/hmg-common/services/push/push.service.ts b/Mohem/src/app/hmg-common/services/push/push.service.ts index 95d50785..c1b5ed3f 100644 --- a/Mohem/src/app/hmg-common/services/push/push.service.ts +++ b/Mohem/src/app/hmg-common/services/push/push.service.ts @@ -222,7 +222,12 @@ export class PushService { this.firebasex.getToken().then(token => { // alert("token: "+ token); + this.cs.sharedService.setSharedData(token, "new-device-token"); + localStorage.setItem('deviceToken', token); + this.cs.setDeviceToken(token); //last way to set the device Token to get it through getDeviceToken + this.registerInBackend(token); + }).catch(error => console.error('Error getting token', error));