content: package org.goormthon.seasonthon.nocheongmaru.global.config;
  
  import java.io.IOException;
  import java.io.InputStream;
  
  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;
  
  @Configuration
  public class FirebaseConfig {
      
      @PostConstruct
      public void init() throws IOException {
          try (InputStream serviceAccount = new ClassPathResource("firebase-service-key.json").getInputStream()) {
              FirebaseOptions options = FirebaseOptions.builder()
                  .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                  .build();
              
              if (FirebaseApp.getApps().isEmpty()) {
                  FirebaseApp.initializeApp(options);
              }
          }
      }
      
      @Bean
      public FirebaseMessaging firebaseMessaging() {
          return FirebaseMessaging.getInstance(FirebaseApp.getInstance());
      }
      
  }