Skip to content

로컬 푸시 구현#93

Merged
kanghun1121 merged 3 commits into
devfrom
feat/local-push
May 7, 2026
Merged

로컬 푸시 구현#93
kanghun1121 merged 3 commits into
devfrom
feat/local-push

Conversation

@kanghun1121

@kanghun1121 kanghun1121 commented Apr 30, 2026

Copy link
Copy Markdown
Member

Summary

매일 저녁 21:00에 식단 기록을 유도하는 로컬 푸시 알림(daily reminder) 기능을 추가합니다.
알림 권한 상태에 따라 자동으로 등록/취소되며, 기존 분석 완료 푸시와의 충돌 없이 분리 처리됩니다.

작업 내용

  • 매일 21:00 식단 기록 리마인더 로컬 푸시 등록 기능 추가
  • 알림 권한 ON이면 등록, OFF면 취소 (포그라운드 진입 시 권한 상태 재평가)
  • 분석 완료 로컬 알림(is_local_notification)과 매일 리마인더(daily_reminder) 알림 분기 분리
  • LocalNotificationScheduler, ScheduleDailyReminderUseCase 단위 테스트 추가

변경 파일

레이어 파일 변경
Domain LocalNotificationScheduling.swift 신규 — 로컬 알림 스케줄링 프로토콜
Domain ScheduleDailyReminderUseCase.swift 신규 — 권한 확인 후 등록/취소 UseCase
Data LocalNotificationScheduler.swift 신규 — UNCalendarNotificationTrigger 기반 구현
App SceneDelegate.swift 수정 — LocalNotificationScheduling, ScheduleDailyReminderUseCase DI 등록
App AppFlowController.swift 수정 — 권한 승인 직후 / 포그라운드 진입 시 tryScheduleDailyReminder() 호출
App AppDelegate.swift 수정 — daily_reminder 알림 분기 추가, 포그라운드 배너 미표시
Tuist InfoPlist+Templates.swift 수정 — NSUserNotificationsUsageDescription 문구 업데이트
Test (Domain) ScheduleDailyReminderUseCaseTests.swift 신규
Test (Domain) Mock/MockLocalNotificationScheduler.swift 신규
Test (Domain) Mock/MockNotificationAuthorizationProvider.swift 신규
Test (Data) LocalNotificationSchedulerTests.swift 신규
Test (Data) Mock/MockUserNotificationCenter.swift 신규

아키텍처

Clean Architecture 의존성 방향을 준수합니다: Domain ← Data ← App

App (AppFlowController)
 └─ ScheduleDailyReminderUseCase  ← Domain
      ├─ LocalNotificationScheduling  ← Domain (protocol)
      │    └─ LocalNotificationScheduler  ← Data (impl)
      └─ NotificationAuthorizationProviding  ← Domain (protocol, 기존)
  • Domain은 LocalNotificationScheduling 프로토콜만 노출, UserNotifications 프레임워크 의존 없음
  • Data의 LocalNotificationScheduler는 내부 UserNotificationCentering 추상화를 통해 UNUserNotificationCenter를 분리, 테스트에서 Mock으로 교체 가능
  • DI는 SceneDelegate에서 등록, AppFlowController에서 resolve

동작 흐름

앱 실행 / 포그라운드 복귀
    └─ AppFlowController.tryScheduleDailyReminder()
            └─ ScheduleDailyReminderUseCase.execute()
                    ├─ 권한 ON  → scheduleDailyReminder(hour: 21, minute: 0)
                    │             (동일 identifier 덮어쓰기 — idempotent)
                    └─ 권한 OFF → cancelDailyReminder()

알림 탭 (UNUserNotificationCenter delegate)
    ├─ notification_type == "daily_reminder"  → 앱 열기만 수행, 딥링크 없음
    └─ is_local_notification == true          → 기존 분석 결과 딥링크 처리 유지

테스트 플랜

  • tuist test — Data, Domain 테스트 통과 확인
  • 시뮬레이터: 알림 권한 허용 후 pending notification 목록에 daily_reminder identifier 확인
  • 시뮬레이터: 권한 거부 상태로 포그라운드 진입 시 리마인더 취소 확인
  • 분석 완료 로컬 알림 탭 시 딥링크 정상 동작 확인 (daily_reminder와 혼용 없음)
  • 매일 리마인더 탭 시 앱만 열리고 딥링크 미실행 확인

@kanghun1121 kanghun1121 changed the title Feat/local push 로컬 푸시 구현 May 1, 2026
@kanghun1121 kanghun1121 marked this pull request as ready for review May 1, 2026 07:10
@kanghun1121 kanghun1121 requested a review from enebin May 1, 2026 07:10
@kanghun1121 kanghun1121 self-assigned this May 1, 2026

@enebin enebin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 하나 있고요 나머지는 굿ㅎㅎ

Comment thread FoodDiary/App/Sources/AppFlowController.swift
@kanghun1121 kanghun1121 merged commit 85cac77 into dev May 7, 2026
1 check passed
@kanghun1121 kanghun1121 deleted the feat/local-push branch May 7, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants