Skip to content

Commit

Permalink
feat: 푸시에 알림 id 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jihoon-jang committed Oct 26, 2023
1 parent 62b60c6 commit b1c78fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public void addNotification(NotificationCreateEvent event) {
}
}

private void sendPushNotification(long memberId, Notification notification) {
private void sendPushNotification(long memberId, Notification notification) {
Member member = userService.findMemberByMemberId(memberId);
NotificationDto notificationDto = notificationService.getNotificationDto(member, notification, false);

firebaseCloudMessageService.sendPushNotification(member, notificationDto.title(), notificationDto.message(),
notificationDto.link());
firebaseCloudMessageService.sendPushNotification(member, notification.getId(), notificationDto.title(),
notificationDto.message(), notificationDto.link());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class FirebaseCloudMessageService {
private static final String SERVER_KEY = "AAAAXWWv8O0:APA91bEPp9GZzMUjTmhmk9n0J5PuX1LvAf-Kaa-vCffntaV85klO-"
+ "gLb4QLf4f9ohrjdIu6L7MOZbaKUReN8CgljU4t1vWWS6BFESQhpZVPQzLhtswju1naFbmHyVNzrHvZWVpHvRNWo";

public void sendPushNotification(Member member, String title, String body, String link) {
public void sendPushNotification(Member member, long id, String title, String body, String link) {
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(FCM_URL);
httpPost.setHeader("Content-Type", "application/json");
Expand All @@ -43,7 +43,8 @@ public void sendPushNotification(Member member, String title, String body, Strin

for (String token : registrationTokens) {
Notification notification = new Notification(title, body, "default");
Map<String, String> data = Map.of("link", link == null ? "" : link, "title", title, "body", body);
Map<String, String> data = Map.of("link", link == null ? "" : link, "title", title, "body", body,
"notificationId", String.valueOf(id));
Message message = new Message(notification, token, data);
ObjectMapper objectMapper = new ObjectMapper();

Expand Down

0 comments on commit b1c78fe

Please sign in to comment.