|
1 |
| -package org.routineade.RoutineAdeServer.config.firebase; |
2 |
| - |
3 |
| -import com.google.auth.oauth2.GoogleCredentials; |
4 |
| -import com.google.firebase.FirebaseApp; |
5 |
| -import com.google.firebase.FirebaseOptions; |
6 |
| -import com.google.firebase.messaging.FirebaseMessaging; |
7 |
| -import java.io.IOException; |
8 |
| -import java.io.InputStream; |
9 |
| -import java.util.List; |
10 |
| -import org.springframework.context.annotation.Bean; |
11 |
| -import org.springframework.context.annotation.Configuration; |
12 |
| -import org.springframework.core.io.ClassPathResource; |
13 |
| - |
14 |
| -@Configuration |
15 |
| -public class FCMConfig { |
16 |
| - @Bean |
17 |
| - FirebaseMessaging firebaseMessaging() throws IOException { |
18 |
| - ClassPathResource resource = new ClassPathResource( |
19 |
| - "firebase/routine-ade-firebase-adminsdk-uime1-11ab5526ac.json"); |
20 |
| - |
21 |
| - InputStream refreshToken = resource.getInputStream(); |
22 |
| - |
23 |
| - FirebaseApp firebaseApp = null; |
24 |
| - List<FirebaseApp> firebaseAppList = FirebaseApp.getApps(); |
25 |
| - |
26 |
| - if (firebaseAppList != null && !firebaseAppList.isEmpty()) { |
27 |
| - for (FirebaseApp app : firebaseAppList) { |
28 |
| - if (app.getName().equals(FirebaseApp.DEFAULT_APP_NAME)) { |
29 |
| - firebaseApp = app; |
30 |
| - } |
31 |
| - } |
32 |
| - } else { |
33 |
| - FirebaseOptions options = FirebaseOptions.builder() |
34 |
| - .setCredentials(GoogleCredentials.fromStream(refreshToken)) |
35 |
| - .build(); |
36 |
| - firebaseApp = FirebaseApp.initializeApp(options); |
37 |
| - } |
38 |
| - |
39 |
| - return FirebaseMessaging.getInstance(firebaseApp); |
40 |
| - } |
41 |
| -} |
| 1 | +//package org.routineade.RoutineAdeServer.config.firebase; |
| 2 | +// |
| 3 | +//import com.google.auth.oauth2.GoogleCredentials; |
| 4 | +//import com.google.firebase.FirebaseApp; |
| 5 | +//import com.google.firebase.FirebaseOptions; |
| 6 | +//import com.google.firebase.messaging.FirebaseMessaging; |
| 7 | +//import java.io.IOException; |
| 8 | +//import java.io.InputStream; |
| 9 | +//import java.util.List; |
| 10 | +//import org.springframework.beans.factory.annotation.Value; |
| 11 | +//import org.springframework.context.annotation.Bean; |
| 12 | +//import org.springframework.context.annotation.Configuration; |
| 13 | +//import org.springframework.core.io.ClassPathResource; |
| 14 | +// |
| 15 | +//@Configuration |
| 16 | +//public class FCMConfig { |
| 17 | +// |
| 18 | +// @Value("${firebase.url}") |
| 19 | +// String FIRE_BASE_FILE_URL; |
| 20 | +// |
| 21 | +// @Bean |
| 22 | +// FirebaseMessaging firebaseMessaging() throws IOException { |
| 23 | +// ClassPathResource resource = new ClassPathResource(FIRE_BASE_FILE_URL); |
| 24 | +// |
| 25 | +// InputStream refreshToken = resource.getInputStream(); |
| 26 | +// |
| 27 | +// FirebaseApp firebaseApp = null; |
| 28 | +// List<FirebaseApp> firebaseAppList = FirebaseApp.getApps(); |
| 29 | +// |
| 30 | +// if (firebaseAppList != null && !firebaseAppList.isEmpty()) { |
| 31 | +// for (FirebaseApp app : firebaseAppList) { |
| 32 | +// if (app.getName().equals(FirebaseApp.DEFAULT_APP_NAME)) { |
| 33 | +// firebaseApp = app; |
| 34 | +// } |
| 35 | +// } |
| 36 | +// } else { |
| 37 | +// FirebaseOptions options = FirebaseOptions.builder() |
| 38 | +// .setCredentials(GoogleCredentials.fromStream(refreshToken)) |
| 39 | +// .build(); |
| 40 | +// firebaseApp = FirebaseApp.initializeApp(options); |
| 41 | +// } |
| 42 | +// |
| 43 | +// return FirebaseMessaging.getInstance(firebaseApp); |
| 44 | +// } |
| 45 | +//} |
0 commit comments