Skip to content

Commit

Permalink
feat: Firebase 클라이언트 구현 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingeun0507 committed Feb 21, 2024
1 parent 0453d56 commit b310857
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void initialize() {
FirebaseApp.initializeApp(options);
}
} catch (final Exception e) {
e.printStackTrace();
throw CustomException.of(ErrorDetails.FIREBASE_INTEGRATION_FAILED);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.guttery.madii.domain.notification.domain.service;

public interface NotificationClient {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.guttery.madii.domain.notification.infrastructure;

import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.guttery.madii.domain.notification.domain.service.NotificationClient;
import org.springframework.stereotype.Component;

@Component
public class FirebaseNotificationClient implements NotificationClient {
public String sendNotification(String content, String token) {
try {
final Message message = Message.builder()
.setToken(token)
.putData("title", content)
.build();

return FirebaseMessaging.getInstance().send(message);

} catch (FirebaseMessagingException e) {
return "Failed";
}
}
}

0 comments on commit b310857

Please sign in to comment.