Skip to content

Commit

Permalink
Merge pull request #97 from EWHA-LUX/feature/#72
Browse files Browse the repository at this point in the history
[Feat] 푸시 알림 페이지 이동을 위한 알림id추가 (#72)
  • Loading branch information
julia-heo authored May 25, 2024
2 parents 6013be1 + d625fda commit 9b4f03e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public class AnnouncementRequestDto {
private String targetToken;
private String title;
private String body;
private String announceId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void cheeringBenefitGoalAnnounce() throws CustomException {
List<FCMToken> fcmTokens = fcmTokenRepository.findAllByUsers(users);
for ( FCMToken fcmToken : fcmTokens){
String token = fcmToken.getToken();
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,"목표 응원 알림",content));
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,"목표 응원 알림",content,announcement.getId().toString()));
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public void cardPerformanceAnnounce() throws CustomException {
List<FCMToken> fcmTokens = fcmTokenRepository.findAllByUsers(users);
for ( FCMToken fcmToken : fcmTokens){
String token = fcmToken.getToken();
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,currentDate+"월 실적 알림",content));
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,currentDate+"월 실적 알림",content,announcement.getId().toString()));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void sendNotification (AnnouncementRequestDto requestDTO) throws CustomEx
Message message = Message.builder()
.setToken(requestDTO.getTargetToken())
.setNotification(notification)
.putData("announceId",requestDTO.getAnnounceId() )
.build();
try {
firebaseMessaging.send(message);
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/ewha/lux/once/domain/home/service/HomeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.time.LocalDate;
Expand All @@ -45,7 +43,6 @@ public class HomeService {
private final FCMTokenRepository fcmTokenRepository;
private final FirebaseCloudMessageService firebaseCloudMessageService;
private final BeaconRepository beaconRepository;
private final CODEFAsyncService codefAsyncService;

// 챗봇 카드 추천
public ChatDto getHomeChat(Users nowUser, String keyword, int paymentAmount) throws CustomException {
Expand Down Expand Up @@ -337,7 +334,7 @@ public void postAnnounceFavorite(AnnounceFavoriteRequestDto dto, Users nowUser)
}

String contents = dto.getStoreName()+" 근처시군요.\n"+card.getName()+" 사용해 보세요!";
String title = dto.getStoreName()+" 근처시군요";
String title = dto.getStoreName()+" 근처시군요.";
String content = card.getName()+" 사용해 보세요!";
String moreInfo = dto.getLatitude()+", "+dto.getLongitude();
Announcement announcement = Announcement.builder()
Expand All @@ -351,7 +348,7 @@ public void postAnnounceFavorite(AnnounceFavoriteRequestDto dto, Users nowUser)
for ( FCMToken fcmToken : fcmTokens){

String token = fcmToken.getToken();
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,title,content));
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,title,content,announcement.getId().toString()));
}
}
public void postBeaconAnnouncement(BeaconRequestDto dto, Users nowUser)throws CustomException {
Expand All @@ -378,7 +375,7 @@ public void postBeaconAnnouncement(BeaconRequestDto dto, Users nowUser)throws Cu
throw new CustomException(ResponseCode.FAILED_TO_OPENAI_RECOMMEND);
}

String title = beacon.getStore()+" 근처시군요";
String title = beacon.getStore()+" 근처시군요.";
String content = card.getName()+" 사용해 보세요!";
String contents = beacon.getStore()+" 근처시군요.\n"+card.getName()+" 사용해 보세요!";

Expand All @@ -393,7 +390,7 @@ public void postBeaconAnnouncement(BeaconRequestDto dto, Users nowUser)throws Cu
announcementRepository.save(announcement);
for ( FCMToken fcmToken : fcmTokens){
String token = fcmToken.getToken();
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,title,content));
firebaseCloudMessageService.sendNotification(new AnnouncementRequestDto(token,title,content,announcement.getId().toString()));
}

}
Expand Down

0 comments on commit 9b4f03e

Please sign in to comment.