This commit is contained in:
Peter Maquiran
2023-08-08 13:43:24 +01:00
9 changed files with 227 additions and 49 deletions
+21 -6
View File
@@ -138,7 +138,7 @@ export class NotificationsService {
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotificationSchema) => {
this.active = true
console.log('NOtification Listener', notification)
this.storenotification(notification)
this.eventtrigger.publishSomeData({
notification: "recive"
@@ -148,7 +148,6 @@ export class NotificationsService {
} else {
this.afMessaging.messages.subscribe((notification) => {
this.storenotification(notification)
this.storenotification(notification)
this.notificationReceived.emit();
this.eventtrigger.publishSomeData({
@@ -160,11 +159,27 @@ export class NotificationsService {
}
storenotification(notification) {
console.log(notification)
console.log('Store Notification ',notification)
this.storageService.get("Notifications").then((store) => {
store.push(notification)
this.storageService.store("Notifications", store)
console.log('Store Notification ',store)
const result = store.reduce((accumulator, current) => {
let exists = accumulator.find(item => {
return item.id === current.id;
});
if(!exists) {
accumulator = accumulator.concat(current);
}
return accumulator;
}, []);
console.log(result);
this.storageService.store("Notifications", result)
}).catch((error) => {
if (!error) {
this.storageService.store("Notifications", [notification])
@@ -180,7 +195,7 @@ export class NotificationsService {
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: ActionPerformed) => {
this.active = true
console.log(notification)
console.log('NOtification Listener Backgroud', notification)
/* this.DataArray.push(notification.notification)
this.storageService.store("Notifications", this.DataArray)
@@ -241,7 +256,7 @@ export class NotificationsService {
this.zone.run(() => this.router.navigate(['/home/agenda', notification.notification.data.IdObject, 'agenda']));
}
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expediente") {
else if (notification.notification.data.Service === "gabinete-digital" && notification.notification.data.Object === "expedientes") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.notification.data.IdObject, 'gabinete-digital']));
}
else if (notification.notification.data.Service === "agenda" && notification.notification.data.Object === "event-list") {