Skip to content

Commit

Permalink
[FIX]fcm정책에 맞게 필드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong0329 committed Jun 30, 2024
1 parent 259cc5b commit d1c2c24
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void postCommentVer2(Long memberId, Long contentId, MultipartFile comment
.description("답글 푸시 알림")
.relateContentId(String.valueOf(contentId))
.build())
.badge(String.valueOf(contentWritingMember.getFcmBadge()))
.badge(contentWritingMember.getFcmBadge())
.build())
.build();

Expand Down Expand Up @@ -197,7 +197,7 @@ public void likeComment(Long memberId, Long commentId, CommentLikedRequestDto co
.description("답글 좋아요 푸시 알림")
.relateContentId(String.valueOf(contentId))
.build())
.badge(String.valueOf(targetMember.getFcmBadge()))
.badge(targetMember.getFcmBadge())
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void likeContent(Long memberId, Long contentId, ContentLikedRequestDto co
.description("게시글 좋아요 푸시 알림")
.relateContentId(String.valueOf(contentId))
.build())
.badge(String.valueOf(targetMember.getFcmBadge()))
.badge(targetMember.getFcmBadge())
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void popularContentNotification() {
.description("인기글 관련 푸시 알림")
.relateContentId(String.valueOf(topContent.getId()))
.build())
.badge(String.valueOf(topContentWriter.getFcmBadge()))
.badge(topContentWriter.getFcmBadge())
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class Message {
private NotificationDetails notificationDetails;
private String token;
private Data data;
private String badge;
private int badge;
}

@Builder
Expand All @@ -29,6 +29,7 @@ public static class Message {
public static class NotificationDetails {
private String title;
private String body;
private Integer badge;
}

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.google.firebase.messaging.*;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -48,10 +46,14 @@ public void sendMessage(FcmMessageDto fcmMessageDto) {
.setBody(fcmMessageDto.getMessage().getNotificationDetails().getBody())
.build()
)
.setApnsConfig(ApnsConfig.builder()
.setAps(Aps.builder()
.setBadge(fcmMessageDto.getMessage().getBadge())
.build())
.build())
.putAllData(objectMapper.convertValue(fcmMessageDto.getMessage().getData(), Map.class))
.putData("badge", fcmMessageDto.getMessage().getBadge())
.build();
System.out.println(fcmMessageDto.getMessage().getBadge());
System.out.println(fcmMessageDto.getMessage().getNotificationDetails().getBadge());
try {
FirebaseMessaging.getInstance().send(message);
} catch (FirebaseMessagingException e) {
Expand Down

0 comments on commit d1c2c24

Please sign in to comment.