fix device token issue

production
ashwaq 6 years ago
parent 4ae7e7566c
commit 8cc0a3fff7

@ -51,7 +51,7 @@ export class AppComponent implements OnInit, AfterViewInit {
} }
ngOnInit() { ngOnInit() {
this.initializeApp(); this.initializeApp();
this.startReceivingPushService();
} }
ngAfterViewInit() {} ngAfterViewInit() {}
initializeApp() { initializeApp() {
@ -65,6 +65,7 @@ export class AppComponent implements OnInit, AfterViewInit {
this.watchLanguageChangeEvents(); this.watchLanguageChangeEvents();
this.subscribeEvents(); this.subscribeEvents();
this.keyboardService.watchKeyboard(); this.keyboardService.watchKeyboard();
this.startReceivingPushService();
}); });
}); });
} }

@ -45,10 +45,10 @@ export class ConfirmLoginComponent implements OnInit {
this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
console.log("deviceToken :"+this.deviceToken); console.log("deviceToken :"+this.deviceToken);
//if device token undefind //if device token undefind
// if(this.deviceToken == undefined){ if(this.deviceToken == undefined){
// alert("undefined"); this.deviceToken = localStorage.getItem("deviceToken");
// this.pushService.startReceiving();
// } }
this.lastLogin = this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false); 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); this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
console.log("loginData : "+ this.loginData); console.log("loginData : "+ this.loginData);
this.deviceToken= this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false); this.deviceToken= this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
if(this.deviceToken == undefined){
this.deviceToken = localStorage.getItem("deviceToken");
}
console.log("deviceToken :"+this.deviceToken); console.log("deviceToken :"+this.deviceToken);
this.loginTypeData= this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false); this.loginTypeData= this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false);
console.log("loginType :"+this.loginTypeData.loginType); console.log("loginType :"+this.loginTypeData.loginType);

@ -222,9 +222,12 @@ export class PushService {
this.oneSignal.endInit(); this.oneSignal.endInit();
this.oneSignal.getIds().then(result => { this.oneSignal.getIds().then(result => {
console.log("result.userId: " +result.userId); console.log("result.userId: " +result.userId);
//there is no part for notLoggedInUserURL () as patient app //there is no part for notLoggedInUserURL () as patient app
if(result.userId){ if(result.userId){
this.cs.sharedService.setSharedData(result.userId, AuthenticationService.DEVICE_TOKEN); this.cs.sharedService.setSharedData(result.userId, AuthenticationService.DEVICE_TOKEN);
localStorage.setItem("deviceToken", result.userId);
} }
this.registerInBackend(result.userId); this.registerInBackend(result.userId);

Loading…
Cancel
Save