Skip to content

[#204] 업데이트 된 FCM 토큰이 Firestore에 남아있는 이슈를 해결한다#305

Merged
opficdev merged 4 commits intodevelopfrom
fix/#304-refresh-fcm-token
Mar 19, 2026
Merged

[#204] 업데이트 된 FCM 토큰이 Firestore에 남아있는 이슈를 해결한다#305
opficdev merged 4 commits intodevelopfrom
fix/#304-refresh-fcm-token

Conversation

@opficdev
Copy link
Owner

@opficdev opficdev self-assigned this Mar 19, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 풀 리퀘스트는 FCM 토큰 및 사용자 시간대와 같은 사용자 데이터를 Firestore와 동기화하는 애플리케이션의 접근 방식을 크게 리팩토링합니다. 전용 핸들러 클래스를 도입하고 알림 기반 통신 패턴을 활용함으로써, 변경 사항은 모듈성과 유지보수성을 향상시킵니다. 이는 사용자 데이터, 특히 FCM 토큰이 백엔드에서 일관되고 올바르게 업데이트되도록 보장하여 이전에 식별된 문제를 해결합니다.

Highlights

  • FCM 토큰 및 사용자 시간대 동기화 핸들러 도입: FCM 토큰 새로고침 및 사용자 시간대 업데이트를 처리하기 위한 전용 FCMTokenSyncHandlerUserTimeZoneSyncHandler 클래스가 추가되었습니다. 이 핸들러들은 NotificationCenter를 통해 이벤트를 수신하고 UserDataRepository를 사용하여 Firestore에 데이터를 동기화합니다.
  • AppDelegate 리팩토링: AppDelegate는 이제 FCM 토큰 및 시간대 업데이트 로직을 직접 처리하는 대신, AppDIContainer를 통해 핸들러를 활성화하고 관련 이벤트를 NotificationCenter에 게시하도록 리팩토링되었습니다. 이는 AppDelegate의 책임을 줄이고 모듈성을 향상시킵니다.
  • 데이터 계층 확장: UserDataRepository 프로토콜과 UserDataRepositoryImpl 구현에 FCM 토큰 및 사용자 시간대 업데이트를 위한 새로운 메서드가 추가되었습니다. UserService도 이러한 업데이트를 처리하도록 수정되어, 사용자 인증 상태를 확인하고 데이터를 Firestore에 저장합니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

이 PR은 FCM 토큰이 갱신될 때 Firestore에 업데이트되지 않던 버그를 성공적으로 수정합니다. AppDelegate의 책임을 줄이고, NotificationCenter와 Handler 객체를 사용하여 FCM 토큰 및 타임존 동기화 로직을 분리한 점이 인상적입니다. 이 리팩토링을 통해 코드의 모듈성과 테스트 용이성이 크게 향상되었습니다. 전반적으로 훌륭한 변경입니다. 레포지토리 스타일 가이드에 따라, 간결하고 실행 가능한 피드백을 한국어로 작성했습니다. 한 가지 개선 제안을 리뷰 댓글로 남겼습니다.

Comment on lines +8 to +34
import Combine
import Foundation

final class UserTimeZoneSyncHandler {
private let repository: UserDataRepository
private let logger = Logger(category: "UserTimeZoneSyncHandler")
private var cancellables = Set<AnyCancellable>()

init(
repository: UserDataRepository,
notificationCenter: NotificationCenter = .default
) {
self.repository = repository

notificationCenter.publisher(for: .didRequestUserTimeZoneSync)
.sink { [weak self] _ in
Task {
do {
try await self?.repository.updateUserTimeZone()
} catch {
self?.logger.error("Failed to sync user timeZone", error: error)
}
}
}
.store(in: &cancellables)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

AppDelegate의 주석(// 앱이 온그라운드로 되었을 때...)을 보면, 앱이 포그라운드로 전환될 때마다 타임존을 동기화하려는 의도가 있었던 것으로 보입니다. 현재 구현은 앱이 처음 시작될 때만 동기화를 요청하고 있어, 이 의도를 완전히 반영하지 못하고 있습니다.

사용자가 앱을 백그라운드로 전환한 후 기기의 시간대를 변경하고 다시 앱으로 돌아오는 경우, 변경된 타임존이 즉시 반영되지 않는 문제가 발생할 수 있습니다.

UIApplication.willEnterForegroundNotification 알림을 추가로 수신하여, 앱이 포그라운드로 진입할 때마다 타임존을 동기화하도록 개선하는 것을 제안합니다. 이렇게 하면 앱의 동작이 주석의 의도와 일치하게 되고, 사용자 경험도 향상될 것입니다.

import Combine
import Foundation
import UIKit

final class UserTimeZoneSyncHandler {
    private let repository: UserDataRepository
    private let logger = Logger(category: "UserTimeZoneSyncHandler")
    private var cancellables = Set<AnyCancellable>()

    init(
        repository: UserDataRepository,
        notificationCenter: NotificationCenter = .default
    ) {
        self.repository = repository

        let launchPublisher = notificationCenter.publisher(for: .didRequestUserTimeZoneSync).map { _ in () }
        let foregroundPublisher = notificationCenter.publisher(for: UIApplication.willEnterForegroundNotification).map { _ in () }

        Publishers.Merge(launchPublisher, foregroundPublisher)
            .sink { [weak self] in
                Task {
                    do {
                        try await self?.repository.updateUserTimeZone()
                    } catch {
                        self?.logger.error("Failed to sync user timeZone", error: error)
                    }
                }
            }
            .store(in: &cancellables)
    }
}

@opficdev opficdev merged commit e7beeab into develop Mar 19, 2026
1 check passed
@opficdev opficdev deleted the fix/#304-refresh-fcm-token branch March 19, 2026 15:12
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 토큰이 업데이트 되지 않는 이슈를 해결한다

1 participant