77
88import UIKit
99import Firebase
10- import FirebaseAuth
1110import GoogleSignIn
1211
1312class AppDelegate : UIResponder , UIApplicationDelegate , MessagingDelegate {
1413 private let logger = Logger ( category: " AppDelegate " )
14+ private let container = AppDIContainer . shared
1515
1616 func application(
1717 _ app: UIApplication ,
@@ -26,8 +26,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
2626 didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? = nil
2727 ) -> Bool {
2828 FirebaseApp . configure ( )
29- _ = AppDIContainer . shared. resolve ( FCMTokenSyncHandler . self)
30-
29+ _ = container. resolve ( FCMTokenSyncHandler . self)
30+ _ = container. resolve ( UserTimeZoneSyncHandler . self)
31+
3132 // 알림 권한 요청
3233 UNUserNotificationCenter . current ( ) . delegate = self
3334 UNUserNotificationCenter . current ( ) . requestAuthorization ( options: [ . alert, . badge, . sound] ) { granted, error in
@@ -42,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
4243 }
4344
4445 // 앱이 온그라운드로 되었을 때, 로그인 세션이 존재한다면 현재 유저의 timeZone 저장
45- updateUserTimeZone ( )
46+ NotificationCenter . default . post ( name : . didRequestUserTimeZoneSync , object : nil )
4647
4748 // Firebase Messaging 설정
4849 Messaging . messaging ( ) . delegate = self
@@ -88,21 +89,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
8889 }
8990}
9091
91- private extension AppDelegate {
92- func updateUserTimeZone( ) {
93- Task {
94- do {
95- guard let uid = Auth . auth ( ) . currentUser? . uid else { return }
96- let settingsRef = Firestore . firestore ( ) . document ( " users/ \( uid) /userData/settings " )
97-
98- try await settingsRef. setData ( [ " timeZone " : TimeZone . autoupdatingCurrent. identifier] , merge: true )
99- } catch {
100- logger. error ( " Failed to update timeZone " , error: error)
101- }
102- }
103- }
104- }
105-
10692extension AppDelegate : UNUserNotificationCenterDelegate {
10793 // 앱이 포그라운드에 있을 때 알림 표시
10894 func userNotificationCenter(
0 commit comments