Limit device registration to customers only

This commit is contained in:
Ben Goldsworthy 2020-11-29 15:59:38 +00:00
parent 3fb5428e8c
commit 83fa5449b8
2 changed files with 5 additions and 4 deletions

View file

@ -12,8 +12,10 @@ export class AppComponent {
constructor(private messagingService: MessagingService) { } constructor(private messagingService: MessagingService) { }
ngOnInit() { ngOnInit() {
if (localStorage.getItem('usertype') === 'customer') {
this.messagingService.requestPermission(); this.messagingService.requestPermission();
this.messagingService.receiveMessage(); this.messagingService.receiveMessage();
this.message = this.messagingService.currentMessage; this.message = this.messagingService.currentMessage;
} }
} }
}

View file

@ -20,7 +20,6 @@ export class MessagingService {
requestPermission() { requestPermission() {
this.angularFireMessaging.requestToken.subscribe((token) => { this.angularFireMessaging.requestToken.subscribe((token) => {
console.log("Device token: " + token);
this.api.addDeviceToken({'token': token, 'email': localStorage.getItem('email')}).subscribe( this.api.addDeviceToken({'token': token, 'email': localStorage.getItem('email')}).subscribe(
result => { result => {
console.log("Device registered successfully!"); console.log("Device registered successfully!");