Skip to content

Commit

Permalink
feat: fcm 전송에 payload 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
twoosky committed Oct 17, 2023
1 parent 61b4b5b commit d171150
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/src/main/java/com/tago/api/infra/fcm/FCMClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public void send(FCMSendDto dto) {

String token = fcmTokenUtil.get(dto.getPhoneNumber());
Message message = Message.builder()
.putData("payload", dto.getPayload())
.putData("title", dto.getTitle())
.putData("content", dto.getContent())
.setToken(token)
.build();

try {
FirebaseMessaging.getInstance().send(message);
String response = FirebaseMessaging.getInstance().send(message);
log.info("## SUCCESS SEND FCM ## " + response);
} catch (FirebaseMessagingException e) {
throw new FailedSendFCMException(e);
}
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/com/tago/api/infra/fcm/FCMSendDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class FCMSendDto {
private String title;
private String content;
private String phoneNumber;
private String payload;
}
1 change: 1 addition & 0 deletions api/src/main/java/com/tago/api/infra/fcm/FCMService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class FCMService {
public void sendByTripMemberEvent(TripMemberEvent event) {
FCMType type = FCMType.from(event.getAction());
fcmClient.send(FCMSendDto.builder()
.payload(String.valueOf(event.getTripId()))
.title(type.getTitle())
.content(type.getContent(event.getName()))
.phoneNumber(event.getPhoneNumber())
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/com/tago/api/infra/fcm/FCMType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.function.Function;
@Getter
public enum FCMType {
CREATE_TRIP_MEMBER("TAGO", (name) -> name + "님! 여행메이트가 한명 추가되었어요! 클릭해서 확인해보세요."),
CREATE_TRIP_MEMBER("TAGO", (name) -> name + "님! 여행인원이 한명 추가되었어요! 클릭해서 확인해보세요."),
DELETE_TRIP_MEMBER("TAGO", (name) -> name + "님! 여행인원이 줄어들었어요. 클릭해서 확인해보세요."),
COMPLETE_TRIP_MEMBER("TAGO", (name) -> name + "님! 여행인원이 모두 모집되었네요! 클릭해서 확인해보세요."),
CREATE_DISPATCH("TAGO", (name) -> name + "님! 여행을 같이 할 기사님이 배정되었어요. 클릭해서 확인해보세요.")
Expand Down

0 comments on commit d171150

Please sign in to comment.