Skip to content

Commit

Permalink
feat: #39 fcm 의존성 추가 && admin key 주입
Browse files Browse the repository at this point in the history
  • Loading branch information
psychology50 committed Feb 24, 2024
1 parent c999cf9 commit 49f5bc4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fitapet-infra/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

## firebase sdk key ###
fitapet-ios-firebase-adminsdk-ethnn-6ec10fe329.json
3 changes: 3 additions & 0 deletions fitapet-infra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.5'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.5'

/* Firebase */
implementation 'com.google.firebase:firebase-admin:9.2.0'

implementation project(':fitapet-common')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package kr.co.fitapet.infra.config;

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

import java.io.IOException;

@Configuration
public class FcmConfig {
private final ClassPathResource firebaseResource = new ClassPathResource("firebase/fitapet-ios-firebase-adminsdk-ethnn-6ec10fe329.json");

@Bean
FirebaseApp firebaseApp() throws IOException {
FirebaseOptions option = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(firebaseResource.getInputStream()))
.build();
return FirebaseApp.initializeApp(option);
}

@Bean
FirebaseMessaging firebaseMessaging() throws IOException {
return FirebaseMessaging.getInstance(firebaseApp());
}
}

0 comments on commit 49f5bc4

Please sign in to comment.