Skip to content

Commit

Permalink
fix: fcm config 수정 (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukmo88 authored Feb 10, 2025
2 parents 15d8541 + 69c9014 commit 320c365
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/com/palbang/unsemawang/config/FirebaseConfig.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
package com.palbang.unsemawang.config;

import java.io.IOException;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.core.io.ClassPathResource;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import java.io.InputStream;

@Slf4j
@Configuration
public class FirebaseConfig {
private FirebaseApp firebaseApp;

@PostConstruct
public FirebaseApp initializeFcm() throws IOException {
// 프로젝트 내부에 있는 JSON 파일 로드

ClassPathResource resource = new ClassPathResource("firebase/serviceAccountKey.json");
InputStream serviceAccount = resource.getInputStream();

FirebaseOptions options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.getApplicationDefault())
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.build();

firebaseApp = FirebaseApp.initializeApp(options);
System.out.println("initializeFcm");
log.info("FirebaseApp initialized");
return firebaseApp;
}
@Bean
Expand Down

0 comments on commit 320c365

Please sign in to comment.