Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] 푸시 알림 페이지 이동을 위한 알림id추가 (#72) #97

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading