-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: production 환경에서의 FCM Configuration 클래스 네이밍 변경 및 profile 설정 추가 * refactor: local 환경에서의 FCM Configuration 클래스 추가
- Loading branch information
Showing
2 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
backend/ddang/src/main/java/com/ddang/ddang/configuration/fcm/LocalFcmConfiguration.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,40 @@ | ||
package com.ddang.ddang.configuration.fcm; | ||
|
||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.FirebaseOptions; | ||
import com.google.firebase.messaging.FirebaseMessaging; | ||
import java.util.List; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
@Configuration | ||
@Profile("local") | ||
public class LocalFcmConfiguration { | ||
|
||
@Bean | ||
public FirebaseMessaging firebaseMessaging() { | ||
final FirebaseApp firebaseApps = findFirebaseApps(); | ||
|
||
return FirebaseMessaging.getInstance(firebaseApps); | ||
} | ||
|
||
private FirebaseApp findFirebaseApps() { | ||
final List<FirebaseApp> apps = FirebaseApp.getApps(); | ||
|
||
if (!apps.isEmpty()) { | ||
for (final FirebaseApp app : apps) { | ||
if (FirebaseApp.DEFAULT_APP_NAME.equals(app.getName())) { | ||
return app; | ||
} | ||
} | ||
} | ||
|
||
final FirebaseOptions options = FirebaseOptions.builder() | ||
.setCredentials(new MockGoogleCredentials("test-token")) | ||
.setProjectId("test-project") | ||
.build(); | ||
|
||
return FirebaseApp.initializeApp(options); | ||
} | ||
} |
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