feat(fcm): 푸시 딥링크 파라미터를 추가해 알림 화면 이동을 지원한다

This commit is contained in:
2026-03-09 14:19:57 +09:00
parent bf6dac173a
commit f5c3c62e68
11 changed files with 127 additions and 12 deletions

View File

@@ -16,6 +16,15 @@ enum class FcmEventType {
CREATE_CONTENT_COMMENT, IN_PROGRESS_AUDITION
}
enum class FcmDeepLinkValue(val value: String) {
LIVE("live"),
CHANNEL("channel"),
CONTENT("content"),
SERIES("series"),
AUDITION("audition"),
COMMUNITY("community")
}
class FcmEvent(
val type: FcmEventType,
val title: String = "",
@@ -32,6 +41,8 @@ class FcmEvent(
val messageId: Long? = null,
val creatorId: Long? = null,
val auditionId: Long? = null,
val deepLinkValue: FcmDeepLinkValue? = null,
val deepLinkId: Long? = null,
val commentParentId: Long? = null,
val myMemberId: Long? = null,
val isAvailableJoinCreator: Boolean? = null,
@@ -166,7 +177,9 @@ class FcmSendListener(
contentId = contentId ?: fcmEvent.contentId,
messageId = messageId ?: fcmEvent.messageId,
creatorId = creatorId ?: fcmEvent.creatorId,
auditionId = auditionId ?: fcmEvent.auditionId
auditionId = auditionId ?: fcmEvent.auditionId,
deepLinkValue = fcmEvent.deepLinkValue,
deepLinkId = fcmEvent.deepLinkId
)
}
}

View File

@@ -8,11 +8,16 @@ import com.google.firebase.messaging.MessagingErrorCode
import com.google.firebase.messaging.MulticastMessage
import com.google.firebase.messaging.Notification
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Service
@Service
class FcmService(private val pushTokenService: PushTokenService) {
class FcmService(
private val pushTokenService: PushTokenService,
@Value("\${server.env}")
private val serverEnv: String
) {
private val logger = LoggerFactory.getLogger(this::class.java)
@Async
@@ -25,7 +30,9 @@ class FcmService(private val pushTokenService: PushTokenService) {
messageId: Long? = null,
contentId: Long? = null,
creatorId: Long? = null,
auditionId: Long? = null
auditionId: Long? = null,
deepLinkValue: FcmDeepLinkValue? = null,
deepLinkId: Long? = null
) {
if (tokens.isEmpty()) return
logger.info("os: $container")
@@ -82,6 +89,11 @@ class FcmService(private val pushTokenService: PushTokenService) {
multicastMessage.putData("audition_id", auditionId.toString())
}
val deepLink = createDeepLink(deepLinkValue, deepLinkId)
if (deepLink != null) {
multicastMessage.putData("deep_link", deepLink)
}
val response = FirebaseMessaging.getInstance().sendEachForMulticast(multicastMessage.build())
val failedTokens = mutableListOf<String>()
@@ -115,6 +127,20 @@ class FcmService(private val pushTokenService: PushTokenService) {
}
}
private fun createDeepLink(deepLinkValue: FcmDeepLinkValue?, deepLinkId: Long?): String? {
if (deepLinkValue == null || deepLinkId == null) {
return null
}
val uriScheme = if (serverEnv.equals("voiceon", ignoreCase = true)) {
"voiceon"
} else {
"voiceon-test"
}
return "$uriScheme://${deepLinkValue.value}/$deepLinkId"
}
fun sendPointGranted(tokens: List<String>, point: Int) {
if (tokens.isEmpty()) return
val data = mapOf(