[GMSS-193] FCM 푸시 수신 및 디바이스 토큰 등록/해제 연동 - #45
Merged
Merged
Conversation
FirebaseMessagingService로 푸시를 수신해 알림으로 표시하고, 세션 인증 상태와 포그라운드 진입 시점마다 알림 권한을 확인해 /api/members/me/device-tokens에 토큰을 등록/해제한다. 로그아웃 시에는 토큰 무효화 전에 해제 API를 먼저 호출한다.
토큰 조회에 타임아웃을 걸어 로그아웃/세션 관찰이 멈추지 않게 하고, 알림 표시 실패가 크래시로 번지지 않도록 방어한다. MainActivity에 새던 권한 체크 중복을 제거하고 권한 요청·포그라운드 재동기화를 Compose 쪽으로 옮겨 기존 스타일과 맞추며, LogoutUseCase 등 새 도메인/데이터 로직에 대한 단위 테스트를 추가한다.
RemoteMessage의 data 페이로드 매핑과, 서비스와 동일한 채널·아이콘·인텐트 구성으로 실제 시스템 알림이 게시되는지를 실기기 계측 테스트로 확인한다.
새로 설치할 때마다 POST_NOTIFICATIONS가 초기화되는 문제로 신규 설치 환경에서 알림 표시 테스트가 실패할 수 있었다. 테스트가 실행 전에 직접 권한을 부여하도록 해 수동 조작 없이도 재현 가능하게 만든다.
세션 인증과 포그라운드 진입이 거의 동시에 동기화를 트리거해 콜드스타트마다 같은 요청이 두 번 나가던 것을 이미 반영된 상태는 건너뛰도록 정리한다. 실패는 기억하지 않아 첫 요청이 401을 받아도 다음 트리거가 복구한다. 응답 본문을 쓰지 않아 200 + success:false 가 성공으로 보고되던 것도 함께 고친다.
soyeonLee126
marked this pull request as ready for review
August 17, 2026 12:40
seunghee17
requested changes
Aug 17, 2026
알림 권한 요청 주체가 develop의 온보딩 안내 다이얼로그와 겹쳤다. 앱 시작 직후 무조건 요청하던 경로를 걷어내고 온보딩이 요청을 소유하도록 정리했다. 온보딩을 거치지 않고 메인으로 들어오는 기존 사용자에게만 한 번 요청한다. 동의와 거절을 모두 안내 이력으로 남겨 실행마다 다시 묻지 않도록 NotificationPermissionPromptHistory를 추가했다.
로그아웃과 달리 탈퇴 경로에는 토큰 해제가 없어 서버가 무효화하지 않으면 삭제된 계정의 토큰이 남는다. 탈퇴가 끝나면 인증이 무효해져 해제 요청을 보낼 수 없으므로 탈퇴 요청 전에 해제한다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 개요
FCM 푸시를 수신해 알림으로 표시하고, 디바이스 토큰을 서버
/api/members/me/device-tokens에 등록/해제하는 흐름을 구현했습니다.작업 유형
변경 사항
GamssFirebaseMessagingService추가 — 푸시 수신 시 알림 표시, 탭하면 앱 홈으로 이동domain/push추가 —DeviceTokenRepository,PushTokenProvider,NotificationPermissionChecker,SyncDeviceTokenUseCase,UnregisterCurrentDeviceTokenUseCase(RemoteConfig 모듈과 동일한 domain/data 분리 구조)DeviceTokenService(Retrofit)로/api/members/me/device-tokensPOST/DELETE 연동Authenticated가 될 때(콜드스타트/로그인 직후)와 앱이 포그라운드로 돌아올 때(백그라운드 중 알림 권한 변경 대응) 각각 토큰 동기화 호출LogoutUseCase가 토큰 무효화 전에 디바이스 토큰 해제 API를 먼저 호출하도록 변경POST_NOTIFICATIONS런타임 권한 요청 및 알림 채널 생성 추가token+ 등록 여부)는 건너뜁니다. 실패는 기억하지 않아, 액세스 토큰 재발급 전 첫 요청이 401을 받아도 다음 트리거가 복구합니다200+success:false가 성공으로 보고되던 문제 수정 (throwIfFailed()적용)관련 이슈
관련 작업 (Notion)
스크린샷 / 동작 화면
실기기(Galaxy S23, Android 16 / API 36)에서 전 구간 확인했습니다.
DELETE /api/members/me/device-tokens→ 200, "허용" 직후POST→ 200channel=push_default,flags=AUTO_CANCEL,icon=ic_notification)체크리스트
develop으로 설정되어 있다feat:,fix:등)을 따른다리뷰 요청 사항
ic_notification.xml)은 임시 플레이스홀더라 디자인 리소스로 교체가 필요합니다.SessionExpiredException으로 변환되어도 세션 무효화로 이어지지는 않습니다(다음 트리거에서 복구되는 것도 확인). 다만 의미상으로는 이 API만treatUnauthorizedAsSessionExpired = false로 두는 게 더 정확할 수 있어 의견 부탁드립니다.System.currentTimeMillis().toInt()로 두어 알림이 계속 쌓입니다. "같은 종류는 갱신·그룹핑" 요구가 있으면 후속으로 다루겠습니다.