fix device token issue

production
ashwaq 6 years ago
parent 4ae7e7566c
commit 8cc0a3fff7

@ -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();
});
});
}

@ -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);
}

@ -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);

@ -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);

Loading…
Cancel
Save