
public String pushNotificationFCM(ProfileDTO profileDTO, SigningTransactionDTO signingTransactionDTO) {
FirebaseApp firebaseApp = null;
try {
.....
log.info(Constants.FCM_LOG_MESSAGE + ": proxy is disabled");
// Loading the resource file from the classpath
Resource resource = new ClassPathResource(fcmKeyPath);
// Creating an InputStream from the resource
try (InputStream inputStream = resource.getInputStream()) {
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(inputStream))
.setServiceAccountId(fcmAccountService)
.build();
if (FirebaseApp.getApps().isEmpty()) {
firebaseApp = FirebaseApp.initializeApp(options);
} else {
firebaseApp = FirebaseApp.getApps().get(0);
}
log.info("Application initialized without proxy");
}
}
} catch (IOException e) {
log.error( e.getMessage());
}
try {
response = FirebaseMessaging.getInstance(firebaseApp).send(message);
} catch (FirebaseMessagingException e) {
log.info(" Error " + response);
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -messaging