mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -13,6 +13,9 @@ import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } fr
|
||||
import { notificationObject } from '../models/notifications';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { AngularFireMessaging } from '@angular/fire/messaging';
|
||||
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -23,6 +26,7 @@ export class NotificationsService {
|
||||
DataArray = new Array();
|
||||
|
||||
|
||||
|
||||
callbacks: {
|
||||
[key: string]: {
|
||||
type: notificationObject,
|
||||
@@ -44,7 +48,8 @@ export class NotificationsService {
|
||||
private router: Router,
|
||||
private zone: NgZone,
|
||||
private eventtrigger: EventTrigger,
|
||||
private afMessaging: AngularFireMessaging,) {
|
||||
private afMessaging: AngularFireMessaging,
|
||||
public NotificationHolderService: NotificationHolderService) {
|
||||
|
||||
}
|
||||
|
||||
@@ -179,45 +184,11 @@ export class NotificationsService {
|
||||
|
||||
|
||||
storenotification(notification) {
|
||||
console.log('Store Notification ',notification)
|
||||
this.storageService.get("Notifications").then((store) => {
|
||||
|
||||
store.push(notification)
|
||||
console.log('Store Notification ',store)
|
||||
|
||||
if(this.platform.is('mobile')) {
|
||||
|
||||
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('Notification Result',result);
|
||||
this.storageService.store("Notifications", result).then(() => {
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
this.storageService.store("Notifications", store).then(() => {
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
})
|
||||
})
|
||||
}
|
||||
}).catch((error) => {
|
||||
if (!error) {
|
||||
this.storageService.store("Notifications", [notification])
|
||||
}
|
||||
})
|
||||
this.NotificationHolderService.addNotification(notification)
|
||||
|
||||
|
||||
}
|
||||
|
||||
onReciveBackground() {
|
||||
|
||||
Reference in New Issue
Block a user