Skip to content

Commit

Permalink
fix: FCM 토픽 Malformed topic name 에러 해결 (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeon0208 authored Jul 25, 2024
1 parent fe73482 commit 6d616c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.ody.common.exception.OdyServerErrorException;
import com.ody.notification.dto.request.EnterMessageRequest;
import com.ody.notification.dto.request.FcmSendRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
Expand All @@ -13,8 +14,9 @@
public class FcmPushSender {

public String sendPushNotification(FcmSendRequest fcmSendRequest) {

Message message = Message.builder()
.setTopic(fcmSendRequest.topic())
.setTopic("/topics/" + fcmSendRequest.topic())
.putData("type", fcmSendRequest.notificationType().name())
.putData("nickname", fcmSendRequest.nickname())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public class FcmSubscriber {

public void subscribeTopic(Meeting meeting, DeviceToken deviceToken) {
try {
String topicName = "/topics/" + meeting.getId().toString();
TopicManagementResponse topicManagementResponse = FirebaseMessaging.getInstance()
.subscribeToTopic(List.of(deviceToken.getDeviceToken()), meeting.getId().toString());
.subscribeToTopic(List.of(deviceToken.getDeviceToken()), topicName);
log.info("모임 구독에 성공했습니다 {}", topicManagementResponse);
} catch (Exception exception) {
log.error(exception.getMessage());
Expand Down

0 comments on commit 6d616c8

Please sign in to comment.