diff --git a/Mohem/src/app/authentication/login/login.component.ts b/Mohem/src/app/authentication/login/login.component.ts index 48ce155c..244012bc 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -45,7 +45,7 @@ export class LoginComponent implements OnInit, OnDestroy { public loginDiv:boolean =true; public welcomeBack:boolean =false; public logo = "assets/icon/login/password.png"; - deviceToken: any; + deviceToken: any=""; user: boolean =false; DeviceType: string; requestGetLoginInfo:any; @@ -67,10 +67,35 @@ export class LoginComponent implements OnInit, OnDestroy { ) { } ngOnInit() { - this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); - console.log("get deviceToken login"+ this.deviceToken) + // this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); + // console.log("get deviceToken login"+ this.deviceToken) + + + this.deviceToken= localStorage.getItem('devicyeToken'); + console.log("let deviceToken" + this.deviceToken); + + if (this.deviceToken) { + console.log('login enabled first time: ' + this.deviceToken); + } else { + console.log("no deviceToken" ); + + this.pushService.startReceiving(); + setTimeout(() => { + this.deviceToken= localStorage.getItem('deviceToken'); + console.log('login enabled second time: ' + this.deviceToken); + + }, 1000); + } + + + setTimeout(() => { + + this.getLastLoginInfo(); + },5000); + + - this.getLastLoginInfo(); + //here will delete below part and depdding on user (response from getMobileInfo) this.username = localStorage.getItem("user"); this.password = localStorage.getItem("password"); //****// @@ -143,20 +168,20 @@ export class LoginComponent implements OnInit, OnDestroy { // this.checkAppUpdated(); // this.checkUserAuthentication(); - let deviceToken = localStorage.getItem('deviceToken'); - console.log("let deviceToken" + deviceToken); + this.deviceToken = localStorage.getItem('deviceToken'); + console.log("let deviceToken" + this.deviceToken); - if (deviceToken) { - console.log('login enabled first time: ' + deviceToken); + if (this.deviceToken) { + console.log('login enabled first time: ' + this.deviceToken); this.checkAppUpdated(); } else { console.log("no deviceToken" ); this.pushService.startReceiving(); setTimeout(() => { - deviceToken = localStorage.getItem('deviceToken'); + this.deviceToken = localStorage.getItem('deviceToken'); this.checkAppUpdated(); - console.log('login enabled second time: ' + deviceToken); + console.log('login enabled second time: ' + this.deviceToken); }, 1000); } } @@ -329,7 +354,6 @@ export class LoginComponent implements OnInit, OnDestroy { /// getLastLoginInfo(){ - this.deviceToken this.requestGetLoginInfo= { DeviceType:this.cs.getDeviceType(), DeviceToken:this.deviceToken//"5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken 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 0cb42314..9b9dcc79 100644 --- a/Mohem/src/app/hmg-common/services/push/push.service.ts +++ b/Mohem/src/app/hmg-common/services/push/push.service.ts @@ -166,6 +166,7 @@ export class PushService { if (data) { this.cs.sharedService.setSharedData(data, AuthenticationService.DEVICE_TOKEN); localStorage.setItem('deviceToken', data); + } if (this.authService.isAuthenticated()) { this.registerAuthenticatedUser(data); @@ -249,4 +250,7 @@ export class PushService { + + + }