Skip to content

Commit

Permalink
Merge pull request #510 from connection-2023/feature/#501
Browse files Browse the repository at this point in the history
Feat(#501): fcm message body->data
  • Loading branch information
j-zzi authored May 11, 2024
2 parents b56bf1f + 1cbd3c6 commit 678758f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/chats/services/chats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class ChatsService {
);

await this.notificationService.sendPushNotification(
receiver,
pushNotificationMessage,
);

Expand Down
2 changes: 1 addition & 1 deletion src/common/interface/common-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 3 additions & 6 deletions src/notification/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class NotificationService {
description,
);

await this.sendPushNotification(target, message);
await this.sendPushNotification(message);

const onlineMap =
await this.notificationRepository.getOnlineMapWithTargetId(target);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
};
}
Expand Down

0 comments on commit 678758f

Please sign in to comment.