Skip to content

Commit f5c77a6

Browse files
committed
refactor: FCMTokenSyncHandler의 중첩 Task를 정리
1 parent 1bfbee3 commit f5c77a6

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

Application/DevLogApp/Sources/App/Handler/FCMTokenSyncHandler.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,25 @@ private extension FCMTokenSyncHandler {
5656
return
5757
}
5858
notificationCenter.post(name: .didRequestRemoteNotificationRegistration, object: nil)
59-
syncCurrentFCMToken()
59+
await syncCurrentFCMToken()
6060
}
6161
}
6262

6363
func handleAPNSToken(_ deviceToken: Data) {
6464
messagingService.setAPNSToken(deviceToken)
65-
syncCurrentFCMToken()
66-
}
67-
68-
func syncCurrentFCMToken() {
6965
Task { [weak self] in
70-
guard let self else { return }
66+
await self?.syncCurrentFCMToken()
67+
}
68+
}
7169

72-
do {
73-
guard let fcmToken = try await messagingService.fetchFCMToken() else {
74-
return
75-
}
76-
try await userService.updateFCMToken(fcmToken)
77-
} catch {
78-
logger.error("Failed to sync current FCM token", error: error)
70+
func syncCurrentFCMToken() async {
71+
do {
72+
guard let fcmToken = try await messagingService.fetchFCMToken() else {
73+
return
7974
}
75+
try await userService.updateFCMToken(fcmToken)
76+
} catch {
77+
logger.error("Failed to sync current FCM token", error: error)
8078
}
8179
}
8280

0 commit comments

Comments
 (0)