Skip to content

Commit

Permalink
Merge pull request #144 from Hanaro-trip-together-bank/feature/dues_paid
Browse files Browse the repository at this point in the history
refactor: fcm 수정
  • Loading branch information
ny2060 authored Jun 7, 2024
2 parents d9203b4 + 4d3f082 commit 6568bd9
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,28 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ResourceUtils;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

@Configuration
public class FirebaseConfig {
@Bean
public FirebaseApp firebaseApp() throws IOException {
InputStream refreshToken = new ClassPathResource("./triptogether-e7bac-firebase-adminsdk-peiki-127517aa66.json").getInputStream();

InputStream resource = new ClassPathResource("./triptogether-e7bac-firebase-adminsdk-peiki-127517aa66.json").getInputStream();
String jsonString = new String(resource.readAllBytes(), StandardCharsets.UTF_8);

// \n을 실제 줄 바꿈으로 변환
String formattedJson = jsonString.replace("\\n", "\n");

InputStream formattedJsonStream = new ByteArrayInputStream(formattedJson.getBytes(StandardCharsets.UTF_8));

FirebaseOptions options = FirebaseOptions
.builder()
.setCredentials(GoogleCredentials.fromStream(refreshToken))
.setCredentials(GoogleCredentials.fromStream(formattedJsonStream))
.build();
return FirebaseApp.initializeApp(options);
}
Expand Down

0 comments on commit 6568bd9

Please sign in to comment.