-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #39 fcm 의존성 추가 && admin key 주입
- Loading branch information
1 parent
c999cf9
commit 49f5bc4
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
fitapet-infra/src/main/java/kr/co/fitapet/infra/config/FcmConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |