diff --git a/apps/api/src/app/notifications/notification/notification.service.ts b/apps/api/src/app/notifications/notification/notification.service.ts index 475ee6b53..9f015f430 100644 --- a/apps/api/src/app/notifications/notification/notification.service.ts +++ b/apps/api/src/app/notifications/notification/notification.service.ts @@ -45,9 +45,7 @@ export class NotificationService extends CrudService { title: notification.title, body: notification.body, icon: 'assets/icons/icon-72x72.png', - data: { - click_url: '/dashboard', - }, + data: notification, vibrate: [200, 100, 200], }; diff --git a/libs/core/src/lib/services/in-memory-data.service.ts b/libs/core/src/lib/services/in-memory-data.service.ts index 7b8829894..a7bd98ad8 100644 --- a/libs/core/src/lib/services/in-memory-data.service.ts +++ b/libs/core/src/lib/services/in-memory-data.service.ts @@ -43,6 +43,7 @@ export class InMemoryDataService implements InMemoryDbService { parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl { const newUrl = url + .replace(/\/notifications\/user/, '/notifications') .replace(/\/datapower\/serviceproxy/, '/serviceproxy') .replace(/\/nas\/cluster/, '/cluster') .replace(/\/layer7\/my.cnf/, '/mycnf'); diff --git a/libs/notifications/src/lib/notifications.handler.ts b/libs/notifications/src/lib/notifications.handler.ts index 99332ab89..1f32b3c0d 100644 --- a/libs/notifications/src/lib/notifications.handler.ts +++ b/libs/notifications/src/lib/notifications.handler.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; import { AddNotification, DeleteNotification, MarkAllAsRead, MarkAsRead } from './notifications.actions'; import { SendWebSocketAction } from '@ngx-starter-kit/socketio-plugin'; import { SwPush } from '@angular/service-worker'; -import { AppNotification } from '@ngx-starter-kit/notifications'; +import { AppNotification } from './app-notification.model'; @Injectable({ providedIn: 'root', @@ -12,7 +12,7 @@ export class NotificationsHandler { constructor(private actions$: Actions, private store: Store, private readonly swPush: SwPush) { this.actions$ .pipe(ofActionSuccessful(DeleteNotification)) - .subscribe(action => {console.log(action); this.store.dispatch(new SendWebSocketAction(action))}); + .subscribe(action => this.store.dispatch(new SendWebSocketAction(action))); this.actions$ .pipe(ofActionSuccessful(MarkAsRead)) .subscribe(action => this.store.dispatch(new SendWebSocketAction(action))); @@ -21,11 +21,10 @@ export class NotificationsHandler { .subscribe(action => this.store.dispatch(new SendWebSocketAction(action))); if (this.swPush.isEnabled) { - // subscribe for new messages for testing - this.swPush.messages.subscribe(message => { - console.log('received push notification in NotificationsHandler', message); - // TODO: - // this.store.dispatch(new AddNotification(message as AppNotification)); + this.swPush.messages.subscribe((message: { notification: Notification }) => { + if (message.notification.data.targetType) { + this.store.dispatch(new AddNotification(new AppNotification(message.notification.data))); + } }); } }