Limit device registration to customers only
This commit is contained in:
parent
2d58603444
commit
5911c4d8ee
2 changed files with 5 additions and 4 deletions
|
@ -12,8 +12,10 @@ export class AppComponent {
|
||||||
constructor(private messagingService: MessagingService) { }
|
constructor(private messagingService: MessagingService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.messagingService.requestPermission();
|
if (localStorage.getItem('usertype') === 'customer') {
|
||||||
this.messagingService.receiveMessage();
|
this.messagingService.requestPermission();
|
||||||
this.message = this.messagingService.currentMessage;
|
this.messagingService.receiveMessage();
|
||||||
|
this.message = this.messagingService.currentMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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!");
|
||||||
|
|
Reference in a new issue