Skip to content

Commit

Permalink
Merge pull request #220 from TeamDon-tBe/fix/#219
Browse files Browse the repository at this point in the history
[FIX] EC2환경에서 fire-base.json매칭 못하는 이슈 해결
  • Loading branch information
Hong0329 authored May 20, 2024
2 parents fa9cfc8 + 721f84b commit bd5dd25
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ public class FcmService {
private String firebaseConfigPath;
@PostConstruct
public void initialize() throws IOException {
// fire-base.json 파일 읽기
ClassPathResource resource = new ClassPathResource("fire-base.json");
GoogleCredentials credentials = GoogleCredentials.fromStream(resource.getInputStream());
FirebaseOptions options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(new FileInputStream(firebaseConfigPath)))
// .setCredentials(GoogleCredentials.fromStream(new ClassPathResource("fire-base.json").getInputStream()))
.setCredentials(credentials)
.build();

// JSON 파일 내용 출력
Map<String, Object> jsonMap = objectMapper.readValue(resource.getInputStream(), Map.class);
System.out.println("fire-base.json 내용: " + jsonMap);

if (FirebaseApp.getApps().isEmpty()) {
FirebaseApp.initializeApp(options);
}
Expand All @@ -49,7 +56,7 @@ public void sendMessage(FcmMessageDto fcmMessageDto) {
.putAllData(objectMapper.convertValue(fcmMessageDto.getMessage().getData(), Map.class))
.build();

try{
try {
FirebaseMessaging.getInstance().send(message);
} catch (FirebaseMessagingException e) {
throw new BadRequestException(e.getMessage());
Expand Down

0 comments on commit bd5dd25

Please sign in to comment.