From 1cbd3c61ba9cb4f73dc2de9e446081ceae888084 Mon Sep 17 00:00:00 2001 From: LJH Date: Sat, 11 May 2024 22:02:08 +0900 Subject: [PATCH] Feat(#501): fcm message body->data --- src/chats/services/chats.service.ts | 1 - src/common/interface/common-interface.ts | 2 +- src/notification/services/notification.service.ts | 9 +++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/chats/services/chats.service.ts b/src/chats/services/chats.service.ts index 198e86cd..94157e0e 100644 --- a/src/chats/services/chats.service.ts +++ b/src/chats/services/chats.service.ts @@ -66,7 +66,6 @@ export class ChatsService { ); await this.notificationService.sendPushNotification( - receiver, pushNotificationMessage, ); diff --git a/src/common/interface/common-interface.ts b/src/common/interface/common-interface.ts index 56d8bc66..a02ee4e9 100644 --- a/src/common/interface/common-interface.ts +++ b/src/common/interface/common-interface.ts @@ -95,6 +95,6 @@ export interface IPaginationOptions { } export interface IPushNotificationMessage { - notification: { title: string; body: string; chatRoomId?: string }; + data: { title: string; body: string; chatRoomId?: string }; token: string; } diff --git a/src/notification/services/notification.service.ts b/src/notification/services/notification.service.ts index 65a8f320..0c33134e 100644 --- a/src/notification/services/notification.service.ts +++ b/src/notification/services/notification.service.ts @@ -52,7 +52,7 @@ export class NotificationService { description, ); - await this.sendPushNotification(target, message); + await this.sendPushNotification(message); const onlineMap = await this.notificationRepository.getOnlineMapWithTargetId(target); @@ -175,10 +175,7 @@ export class NotificationService { await this.notificationRepository.deleteNotification(notificationId); } - async sendPushNotification( - target: INotificationTarget, - message: IPushNotificationMessage, - ) { + async sendPushNotification(message: IPushNotificationMessage) { const response = await admin.messaging().send(message); this.logger.log(response); @@ -313,7 +310,7 @@ export class NotificationService { const userDeviceToken = await this.getUserDeviceToken(userId); return { - notification: { title, body, chatRoomId }, + data: { title, body, chatRoomId }, token: userDeviceToken.deviceToken, }; }