-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0453d56
commit b310857
Showing
3 changed files
with
28 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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/guttery/madii/domain/notification/domain/service/NotificationClient.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,4 @@ | ||
package com.guttery.madii.domain.notification.domain.service; | ||
|
||
public interface NotificationClient { | ||
} |
24 changes: 24 additions & 0 deletions
24
...java/com/guttery/madii/domain/notification/infrastructure/FirebaseNotificationClient.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,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"; | ||
} | ||
} | ||
} |