오디션 생성 푸시를 받으면 오디션 탭으로 이동하도록 수정

This commit is contained in:
Yu Sung 2025-01-09 00:38:29 +09:00
parent b5b53f95c7
commit 7481637fbb
3 changed files with 25 additions and 1 deletions

View File

@ -97,6 +97,7 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
let contentIdString = userInfo["content_id"] as? String
let channelIdString = userInfo["channel_id"] as? String
let messageIdString = userInfo["message_id"] as? String
let auditionIdString = userInfo["audition_id"] as? String
if let roomIdString = roomIdString, let roomId = Int(roomIdString), roomId > 0 {
AppState.shared.pushRoomId = roomId
@ -114,6 +115,15 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
AppState.shared.pushMessageId = messageId
}
if let auditionIdString = auditionIdString, let auditionId = Int(auditionIdString), auditionId > 0 {
AppState.shared.startTab = .audition
NotificationCenter.default.post(name: .didReceiveHomeTab, object: HomeViewModel.CurrentTab.audition)
}
completionHandler()
}
}
extension Notification.Name {
static let didReceiveHomeTab = Notification.Name("didReceiveHomeTab")
}

View File

@ -42,6 +42,7 @@ class AppState: ObservableObject {
@Published var purchasedContentOrderType = OrderType.KEEP
@Published var isChangeAdultContentVisible = false
@Published var startTab: HomeViewModel.CurrentTab = .content
func setAppStep(step: AppStep) {
switch step {

View File

@ -24,7 +24,20 @@ final class HomeViewModel: ObservableObject {
case content, live, audition, message, mypage
}
@Published var currentTab: CurrentTab = .content
@Published var currentTab: CurrentTab = AppState.shared.startTab
init() {
NotificationCenter.default
.publisher(for: .didReceiveHomeTab)
.compactMap {
$0.object as? CurrentTab
}
.sink { [weak self] currentTab in
AppState.shared.setAppStep(step: .main)
self?.currentTab = currentTab
}
.store(in: &subscription)
}
func pushTokenUpdate(pushToken: String) {
userRepository.updatePushToken(pushToken: pushToken)