[#204] 업데이트 된 FCM 토큰이 Firestore에 남아있는 이슈를 해결한다#305
Conversation
opficdev
commented
Mar 19, 2026
- closed FCM 토큰이 업데이트 되지 않는 이슈를 해결한다 #304
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
이 PR은 FCM 토큰이 갱신될 때 Firestore에 업데이트되지 않던 버그를 성공적으로 수정합니다. AppDelegate의 책임을 줄이고, NotificationCenter와 Handler 객체를 사용하여 FCM 토큰 및 타임존 동기화 로직을 분리한 점이 인상적입니다. 이 리팩토링을 통해 코드의 모듈성과 테스트 용이성이 크게 향상되었습니다. 전반적으로 훌륭한 변경입니다. 레포지토리 스타일 가이드에 따라, 간결하고 실행 가능한 피드백을 한국어로 작성했습니다. 한 가지 개선 제안을 리뷰 댓글로 남겼습니다.
| 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) | ||
| } | ||
| } |
There was a problem hiding this comment.
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)
}
}