1010import com .example .busnotice .global .code .ErrorCode ;
1111import com .example .busnotice .global .code .StatusCode ;
1212import com .example .busnotice .global .exception .UserException ;
13+ import com .fasterxml .jackson .core .JsonProcessingException ;
14+ import com .fasterxml .jackson .databind .ObjectMapper ;
1315import com .google .firebase .messaging .FirebaseMessaging ;
1416import com .google .firebase .messaging .FirebaseMessagingException ;
1517import com .google .firebase .messaging .Message ;
@@ -34,7 +36,7 @@ public class FCMService {
3436 private final UserRepository userRepository ;
3537 private final ScheduleService scheduleService ;
3638 private final ScheduleRepository scheduleRepository ;
37-
39+ ObjectMapper objectMapper = new ObjectMapper (); // JSON 변환기
3840 @ Transactional
3941 public void createFCMToken (Long userId , CreateFCMTokenRequest createFCMTokenRequest ) {
4042 User user = userRepository .findById (userId ).orElseThrow (
@@ -54,7 +56,7 @@ public void createFCMToken(Long userId, CreateFCMTokenRequest createFCMTokenRequ
5456
5557 @ Scheduled (fixedRate = 60000 ) // 1분(60,000ms)마다 실행
5658 @ Transactional (readOnly = true ) // 트랜잭션 적용
57- public void sendNotification () throws UnsupportedEncodingException {
59+ public void sendNotification () throws UnsupportedEncodingException , JsonProcessingException {
5860 List <FCMToken > allTokens = fcmRepository .findAll ();
5961 List <UserNotificationData > notifications = new ArrayList <>();
6062
@@ -109,7 +111,7 @@ public void sendNotification() throws UnsupportedEncodingException {
109111 .setToken (notification .token ())
110112 .putData ("scheduleName" , notification .scheduleName ())
111113 .putData ("days" , notification .days ().toString ())
112- .putData ("busStopInfos" , notification .busStopInfos (). toString ( ))
114+ .putData ("busStopInfos" , objectMapper . writeValueAsString ( notification .busStopInfos ()))
113115 .build ();
114116
115117 try {
0 commit comments