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

@@ -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(