fix(notification): 푸시 딥링크 우선 실행 분기를 보정한다

This commit is contained in:
Yu Sung
2026-03-13 11:34:10 +09:00
parent af8813685e
commit d5d5d97c2a
5 changed files with 45 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ enum AppDeepLinkHandler {
switch action { switch action {
case .live(let roomId): case .live(let roomId):
guard roomId > 0 else { return } guard roomId > 0 else { return }
AppState.shared.isPushRoomFromDeepLink = true
AppState.shared.pushRoomId = 0 AppState.shared.pushRoomId = 0
AppState.shared.pushRoomId = roomId AppState.shared.pushRoomId = roomId

View File

@@ -265,6 +265,15 @@ extension AppDelegate : UNUserNotificationCenterDelegate {
// With swizzling disabled you must let Messaging know about the message, for Analytics // With swizzling disabled you must let Messaging know about the message, for Analytics
Messaging.messaging().appDidReceiveMessage(userInfo) Messaging.messaging().appDidReceiveMessage(userInfo)
Notifly.userNotificationCenter(center, didReceive: response) Notifly.userNotificationCenter(center, didReceive: response)
let deepLinkString = (userInfo["deep_link"] as? String ?? "")
.trimmingCharacters(in: .whitespacesAndNewlines)
if !deepLinkString.isEmpty {
_ = AppDeepLinkHandler.handle(urlString: deepLinkString)
completionHandler()
return
}
let roomIdString = userInfo["room_id"] as? String let roomIdString = userInfo["room_id"] as? String
let contentIdString = userInfo["content_id"] as? String let contentIdString = userInfo["content_id"] as? String

View File

@@ -50,6 +50,7 @@ class AppState: ObservableObject {
@Published var pushAudioContentId = 0 @Published var pushAudioContentId = 0
@Published var pushSeriesId = 0 @Published var pushSeriesId = 0
@Published var pendingDeepLinkAction: AppDeepLinkAction? = nil @Published var pendingDeepLinkAction: AppDeepLinkAction? = nil
@Published var isPushRoomFromDeepLink = false
@Published var roomId = 0 { @Published var roomId = 0 {
didSet { didSet {
if roomId <= 0 { if roomId <= 0 {

View File

@@ -319,17 +319,22 @@ struct HomeView: View {
} }
let roomId = value let roomId = value
let isPushRoomFromDeepLink = appState.isPushRoomFromDeepLink
appState.pushRoomId = 0 appState.pushRoomId = 0
appState.isPushRoomFromDeepLink = false
DispatchQueue.main.async { DispatchQueue.main.async {
handleExternalNavigationRequest( handleExternalNavigationRequest(
value: roomId, value: roomId,
navigationAction: { navigationAction: {
appState.setAppStep(step: .main) if !isPushRoomFromDeepLink {
appState.setAppStep(step: .main)
}
liveViewModel.enterLiveRoom(roomId: roomId) liveViewModel.enterLiveRoom(roomId: roomId)
}, },
cancelAction: { cancelAction: {
appState.pushRoomId = 0 appState.pushRoomId = 0
appState.isPushRoomFromDeepLink = false
} }
) )
} }

View File

@@ -0,0 +1,28 @@
# 20260313 푸시 터치 딥링크 실행 분기 수정
## 작업 목표
- 푸시 메시지 터치 시 `deep_link` 파라미터가 비어 있지 않으면 딥링크를 우선 실행하고, 비어 있으면 기존 푸시 이동 로직을 유지한다.
- 앱 실행 상태에 따라 딥링크 실행 시점을 분리한다.
- 실행 중: 메인 페이지 재호출 없이 현재 페이지에서 목적지로 이동
- 미실행(콜드 스타트): `HomeView` 표시 이후 딥링크 실행
## 구현 체크리스트
- [x] 푸시 터치 payload에서 `deep_link` 파라미터 파싱 및 우선 실행 분기 추가
- [x] `deep_link` 미존재/빈 값일 때 기존 `push*` 기반 이동 로직 유지
- [x] 앱 실행 상태별(실행 중/미실행) 딥링크 실행 타이밍 보정
- [x] 진단/빌드/테스트 검증 및 결과 기록
## 검증 기록
- 무엇/왜/어떻게: `UNUserNotificationCenterDelegate`의 푸시 탭 진입점(`AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)`)에서 `deep_link`가 비어 있지 않으면 `AppDeepLinkHandler.handle(urlString:)`를 우선 실행하고 즉시 종료하도록 분기했다. `deep_link`가 비어 있을 때만 기존 `room_id/content_id/channel_id/message_id` 파싱 로직을 유지해 기존 이동 흐름을 보존했다.
- 무엇/왜/어떻게: 앱 실행 중 딥링크 라이브 이동에서 기존 `.main` 재호출을 막기 위해 `AppState.isPushRoomFromDeepLink` 플래그를 추가하고, `AppDeepLinkHandler``.live` 액션에서 플래그를 세운 뒤 `HomeView``pushRoomId` 처리에서 플래그가 `true`일 때 `.main` 호출 없이 바로 `liveViewModel.enterLiveRoom(roomId:)`를 수행하도록 수정했다.
- 무엇/왜/어떻게: 앱 미실행(콜드 스타트) 시 딥링크 실행 타이밍은 기존 `AppDeepLinkHandler.handle``pendingDeepLinkAction` 큐잉과 `SplashView.nextAppStep()``setAppStep(.main)` 이후 지연 실행 구조를 그대로 사용해 `HomeView` 표시 이후 딥링크가 실행되도록 유지했다.
- 실행 명령: `lsp_diagnostics` (`SodaLive/Sources/App/AppDelegate.swift`, `SodaLive/Sources/App/AppState.swift`, `SodaLive/Sources/App/AppDeepLinkHandler.swift`, `SodaLive/Sources/Main/Home/HomeView.swift`)
- 결과: 로컬 SourceKit 단독 컨텍스트에서 `No such module 'UIKit'`, `No such module 'Firebase'` 및 연쇄 참조 미해결이 발생했다. 코드 유효성은 아래 빌드 명령으로 재검증했다.
- 실행 명령: `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive" -configuration Debug build`
- 결과: `** BUILD SUCCEEDED **`
- 실행 명령: `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive-dev" -configuration Debug build`
- 결과: `** BUILD SUCCEEDED **`
- 실행 명령: `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive" test`
- 결과: `Scheme SodaLive is not currently configured for the test action.`
- 실행 명령: `xcodebuild -workspace "SodaLive.xcworkspace" -scheme "SodaLive-dev" test`
- 결과: `Scheme SodaLive-dev is not currently configured for the test action.`