Skip to content

[#686] FCM token 동기화 요청을 사용자와 token 기준으로 제한한다#688

Merged
opficdev merged 1 commit into
developfrom
fix/#686-fcmToken
Jul 3, 2026
Merged

[#686] FCM token 동기화 요청을 사용자와 token 기준으로 제한한다#688
opficdev merged 1 commit into
developfrom
fix/#686-fcmToken

Conversation

@opficdev

@opficdev opficdev commented Jul 3, 2026

Copy link
Copy Markdown
Owner

🔗 연관된 이슈

🎯 의도

  • FCM token 동기화가 로그인 세션 전이, token refresh, APNs token 수신, foreground 복귀 흐름에서 반복 요청될 수 있어 같은 사용자와 같은 FCM token 조합은 서버 저장을 반복하지 않도록 제한

📝 작업 내용

📌 요약

  • foreground 복귀 시 scene lifecycle에서 동작하는 notification 기반 APNs 등록 요청으로 변경
  • FCMTokenSyncHandler에 마지막 성공 동기화 key 캐시 추가
  • 같은 (uid, fcmToken) 조합의 반복 저장 방지 테스트 추가

🔍 상세

  • UIApplication.willEnterForegroundNotification을 관찰해 .didRequestAPNsRegistration을 전달하도록 변경
  • 기존 applicationWillEnterForeground(_:) 의존 제거
  • SyncKey(uid:fcmToken:) 기준으로 마지막 성공 동기화 상태를 저장
  • 로그아웃 상태 전이 시 FCM token 동기화 캐시 초기화
  • updateFCMToken(_:) 성공 후에만 캐시를 갱신하도록 처리
  • 같은 사용자/같은 token, 사용자 변경, token 변경, 로그아웃 후 재로그인, 저장 실패 후 재시도 케이스 테스트 추가

📸 영상 / 이미지 (Optional)

@opficdev opficdev self-assigned this Jul 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request optimizes FCM token synchronization by introducing an in-memory cache (lastSyncedKey) to prevent redundant sync requests, updates AppDelegate to trigger APNs registration when entering the foreground, and adds corresponding unit tests. The review feedback suggests removing the in-memory cache to ensure server consistency and avoiding @MainActor isolation on FCMTokenSyncHandler to prevent unnecessary isolation requirements in DI containers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread Application/App/Sources/App/Handler/FCMTokenSyncHandler.swift
@opficdev opficdev merged commit c79472b into develop Jul 3, 2026
10 of 12 checks passed
@opficdev opficdev deleted the fix/#686-fcmToken branch July 3, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FCM token 동기화 요청을 사용자와 token 기준으로 제한한다

1 participant