Skip to content

Commit

Permalink
test: 푸시 알림 테스트 api
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyu0218 committed Dec 18, 2024
1 parent f20a492 commit 3eae7b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,19 @@ public void sendNotificationWithData(String title, String body, String topic) {
throw new BaseException(ErrorCode.FAILED_TO_SEND_GROUP_MESSAGE, e);
}
}

// TODO: 확인 후 삭제 필요
public void sendTest(String token) {
Message message = Message.builder()
.setNotification(null)
.putData("hello", "world")
.setToken(token)
.build();

try {
FirebaseMessaging.getInstance().send(message);
} catch (FirebaseMessagingException e) {
throw new BaseException(ErrorCode.FAILED_TO_SEND_INDIVIDUAL_MESSAGE, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public interface PushMessageSender {
void sendGroupData(final String title, final String body, final String topic, final Long missionId);

void sendNotificationWithData(final String title, final String body, final String topic);

void sendTest(String token);
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,15 @@ ResponseEntity<Void> sendNotificationWithData(

return ResponseEntity.ok().build();
}

@Operation
@GetMapping("test")
ResponseEntity<Void> sendTest(
@Schema(description = "deviceToken", requiredMode = Schema.RequiredMode.REQUIRED)
@RequestParam final String deviceToken
) {
pushMessageSender.sendTest(deviceToken);

return ResponseEntity.ok().build();
}
}

0 comments on commit 3eae7b5

Please sign in to comment.