diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 58867d67..364b64a6 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -51,7 +51,7 @@ export class AppComponent implements OnInit, AfterViewInit { } ngOnInit() { this.initializeApp(); - this.startReceivingPushService(); + } ngAfterViewInit() {} initializeApp() { @@ -65,6 +65,7 @@ export class AppComponent implements OnInit, AfterViewInit { this.watchLanguageChangeEvents(); this.subscribeEvents(); this.keyboardService.watchKeyboard(); + this.startReceivingPushService(); }); }); } diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts index aebf22af..3eb241b9 100644 --- a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts @@ -45,10 +45,10 @@ export class ConfirmLoginComponent implements OnInit { this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); console.log("deviceToken :"+this.deviceToken); //if device token undefind - // if(this.deviceToken == undefined){ - // alert("undefined"); - // this.pushService.startReceiving(); - // } + if(this.deviceToken == undefined){ + this.deviceToken = localStorage.getItem("deviceToken"); + + } this.lastLogin = this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false); } diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.ts b/Mohem/src/app/authentication/sms-page/sms-page.page.ts index 2e557a03..f2dd4a85 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -56,7 +56,10 @@ export class SmsPageComponent implements OnInit { this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); console.log("loginData : "+ this.loginData); this.deviceToken= this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); - + if(this.deviceToken == undefined){ + this.deviceToken = localStorage.getItem("deviceToken"); + + } console.log("deviceToken :"+this.deviceToken); this.loginTypeData= this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false); console.log("loginType :"+this.loginTypeData.loginType); 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 386d6746..035112df 100644 --- a/Mohem/src/app/hmg-common/services/push/push.service.ts +++ b/Mohem/src/app/hmg-common/services/push/push.service.ts @@ -222,9 +222,12 @@ export class PushService { this.oneSignal.endInit(); this.oneSignal.getIds().then(result => { console.log("result.userId: " +result.userId); + //there is no part for notLoggedInUserURL () as patient app if(result.userId){ this.cs.sharedService.setSharedData(result.userId, AuthenticationService.DEVICE_TOKEN); + localStorage.setItem("deviceToken", result.userId); + } this.registerInBackend(result.userId);