Skip to content

Commit

Permalink
chore: (#261) 알림 전송시 type 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut committed Dec 30, 2022
1 parent 8c1d438 commit 06697ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package team.comit.simtong.domain.notification.spi

import team.comit.simtong.domain.notification.model.NotificationType
import java.util.UUID

/**
Expand All @@ -11,9 +12,8 @@ import java.util.UUID
* @version 1.1.0
**/
interface SendPushMessagePort {
fun sendMessage(token: String, title: String, content: String, type: NotificationType, identify: UUID?)

fun sendMessage(tokens: List<String>, title: String, content: String, identify: UUID?)

fun sendMessage(token: String, title: String, content: String, identify: UUID?)
fun sendMessage(tokens: List<String>, title: String, content: String, type: NotificationType, identify: UUID?)

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.google.firebase.messaging.Message
import com.google.firebase.messaging.MulticastMessage
import com.google.firebase.messaging.Notification
import org.springframework.stereotype.Component
import team.comit.simtong.domain.notification.model.NotificationType
import team.comit.simtong.domain.notification.spi.SendPushMessagePort
import java.util.UUID

Expand All @@ -21,9 +22,10 @@ import java.util.UUID
@Component
class FcmAdapter : SendPushMessagePort {

override fun sendMessage(tokens: List<String>, title: String, content: String, identify: UUID?) {
val multicastMessage = MulticastMessage.builder()
.addAllTokens(tokens)
override fun sendMessage(token: String, title: String, content: String, type: NotificationType, identify: UUID?) {
val message = Message.builder()
.setToken(token)
.putData("type", type.name)
.putData("identify", identify.toString())
.setNotification(
Notification.builder()
Expand All @@ -38,12 +40,13 @@ class FcmAdapter : SendPushMessagePort {
)
.build()

FirebaseMessaging.getInstance().sendMulticastAsync(multicastMessage)
FirebaseMessaging.getInstance().sendAsync(message)
}

override fun sendMessage(token: String, title: String, content: String, identify: UUID?) {
val message = Message.builder()
.setToken(token)
override fun sendMessage(tokens: List<String>, title: String, content: String, type: NotificationType, identify: UUID?) {
val multicastMessage = MulticastMessage.builder()
.addAllTokens(tokens)
.putData("type", type.name)
.putData("identify", identify.toString())
.setNotification(
Notification.builder()
Expand All @@ -58,6 +61,6 @@ class FcmAdapter : SendPushMessagePort {
)
.build()

FirebaseMessaging.getInstance().sendAsync(message)
FirebaseMessaging.getInstance().sendMulticastAsync(multicastMessage)
}
}

0 comments on commit 06697ed

Please sign in to comment.