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

@@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.admin.audition.role.AdminAuditionRoleRepository
import kr.co.vividnext.sodalive.audition.AuditionStatus
import kr.co.vividnext.sodalive.aws.s3.S3Uploader
import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.utils.generateFileName
@@ -95,7 +96,9 @@ class AdminAuditionService(
messageKey = "admin.audition.fcm.message.new",
args = listOf(audition.title),
isAuth = audition.isAdult,
auditionId = audition.id ?: -1
auditionId = audition.id ?: -1,
deepLinkValue = FcmDeepLinkValue.AUDITION,
deepLinkId = audition.id
)
)
}

View File

@@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.can.use.UseCanCalculateRepository
import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.i18n.LangContext
@@ -331,7 +332,10 @@ class AdminLiveService(
title = room.member!!.nickname,
messageKey = "live.room.fcm.message.canceled",
args = listOf(room.title),
pushTokens = pushTokens
pushTokens = pushTokens,
roomId = room.id,
deepLinkValue = FcmDeepLinkValue.LIVE,
deepLinkId = room.id
)
)
}

View File

@@ -28,6 +28,7 @@ import kr.co.vividnext.sodalive.content.translation.ContentTranslationRepository
import kr.co.vividnext.sodalive.content.translation.TranslatedContent
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.i18n.LangContext
@@ -463,7 +464,9 @@ class AudioContentService(
message = audioContent.title,
recipients = listOf(audioContent.member!!.id!!),
isAuth = null,
contentId = contentId
contentId = contentId,
deepLinkValue = FcmDeepLinkValue.CONTENT,
deepLinkId = contentId
)
)
@@ -478,7 +481,9 @@ class AudioContentService(
args = listOf(audioContent.title),
isAuth = audioContent.isAdult,
contentId = contentId,
creatorId = audioContent.member!!.id
creatorId = audioContent.member!!.id,
deepLinkValue = FcmDeepLinkValue.CONTENT,
deepLinkId = contentId
)
)
}
@@ -500,7 +505,9 @@ class AudioContentService(
args = listOf(audioContent.title),
isAuth = audioContent.isAdult,
contentId = audioContent.id!!,
creatorId = audioContent.member!!.id
creatorId = audioContent.member!!.id,
deepLinkValue = FcmDeepLinkValue.CONTENT,
deepLinkId = audioContent.id!!
)
)
}

View File

@@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.content.AudioContentRepository
import kr.co.vividnext.sodalive.content.LanguageDetectEvent
import kr.co.vividnext.sodalive.content.LanguageDetectTargetType
import kr.co.vividnext.sodalive.content.order.OrderRepository
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.i18n.LangContext
@@ -91,7 +92,9 @@ class AudioContentCommentService(
args = listOf(audioContent.title),
contentId = audioContentId,
commentParentId = parentId,
myMemberId = member.id
myMemberId = member.id,
deepLinkValue = FcmDeepLinkValue.CONTENT,
deepLinkId = audioContentId
)
)

View File

@@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.explorer.profile.PostWriteCheersRequest
import kr.co.vividnext.sodalive.explorer.profile.PutWriteCheersRequest
import kr.co.vividnext.sodalive.explorer.profile.channelDonation.ChannelDonationService
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.CreatorCommunityService
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.i18n.Lang
@@ -667,7 +668,9 @@ class ExplorerService(
type = FcmEventType.CHANGE_NOTICE,
title = member.nickname,
messageKey = "explorer.notice.fcm.message",
creatorId = member.id!!
creatorId = member.id!!,
deepLinkValue = FcmDeepLinkValue.CHANNEL,
deepLinkId = member.id!!
)
)
}

View File

@@ -17,6 +17,7 @@ import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like.CreatorCo
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like.PostCommunityPostLikeRequest
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.like.PostCommunityPostLikeResponse
import kr.co.vividnext.sodalive.extensions.getTimeAgoString
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.i18n.LangContext
@@ -124,7 +125,9 @@ class CreatorCommunityService(
type = FcmEventType.CHANGE_NOTICE,
title = member.nickname,
messageKey = "creator.community.fcm.new_post",
creatorId = member.id!!
creatorId = member.id!!,
deepLinkValue = FcmDeepLinkValue.COMMUNITY,
deepLinkId = member.id!!
)
)
}

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(

View File

@@ -19,6 +19,7 @@ import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.fcm.FcmDeepLinkValue
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.fcm.PushTokenRepository
@@ -489,6 +490,8 @@ class LiveRoomService(
isAvailableJoinCreator = createdRoom.isAvailableJoinCreator,
roomId = createdRoom.id,
creatorId = createdRoom.member!!.id,
deepLinkValue = FcmDeepLinkValue.LIVE,
deepLinkId = createdRoom.id,
genderRestriction = createdRoom.genderRestriction
)
)
@@ -662,6 +665,8 @@ class LiveRoomService(
isAvailableJoinCreator = room.isAvailableJoinCreator,
roomId = room.id,
creatorId = room.member!!.id,
deepLinkValue = FcmDeepLinkValue.LIVE,
deepLinkId = room.id,
genderRestriction = room.genderRestriction
)
)
@@ -729,7 +734,10 @@ class LiveRoomService(
title = room.member!!.nickname,
messageKey = "live.room.fcm.message.canceled",
args = listOf(room.title),
pushTokens = pushTokens
pushTokens = pushTokens,
roomId = room.id,
deepLinkValue = FcmDeepLinkValue.LIVE,
deepLinkId = room.id
)
)
}