-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 알림 기능 구현 #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: 알림 기능 구현 #239
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a9a78d1
[BOOK-365] feat: add notification-related APIs
clxxrlove 762d6ff
[BOOK-365] feat: implement FCM token persistence and retrieval
clxxrlove 78252f2
[BOOK-365] feat: implement FCM token repository
clxxrlove 3f3acc8
[BOOK-365] feat: implement FCM token usecase
clxxrlove 3888682
[BOOK-365] chore: add FirebaseMessaging dependency and configure APNs
clxxrlove da2a6fa
[BOOK-365] feat: configure FCM/APNs in AppDelegate
clxxrlove 1c06a97
[BOOK-365] feat: sync FCM token with server in AppCoordinator
clxxrlove bf81a81
[BOOK-365] refactor: rename WebPresenting → URLPresenting and support…
clxxrlove 5412946
[BOOK-365] feat: add NotificationSettings
clxxrlove a8aa8fd
[BOOK-365] feat: add Notification Settings entry
clxxrlove d74a82b
[BOOK-365] fix: resolve ui timing issue
clxxrlove 787e500
[BOOK-365] feat: update view to react to system notification settings
clxxrlove 42cd1ba
[BOOK-365] feat: add convenience method to convert AuthError into Dom…
clxxrlove d8da93b
[BOOK-365] chore: remove duplicated keys
clxxrlove f87bae2
[BOOK-365] fix: adjust timing of system notification permission request
clxxrlove 00e3ac9
[BOOK-365] chore: remove duplicated keys
clxxrlove 151af29
[BOOK-365] fix: resolve DI violation
clxxrlove d132a58
[BOOK-365] fix: resolve build error
clxxrlove File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Projects/BKData/Sources/DTO/Request/NotificationStatusRequestDTO.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import Foundation | ||
|
|
||
| struct NotificationStatusRequestDTO: Encodable { | ||
| let notificationEnabled: Bool | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Projects/BKData/Sources/DTO/Request/UpsertFCMTokenRequestDTO.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import Foundation | ||
|
|
||
| struct UpsertFCMTokenRequestDTO: Encodable { | ||
| let fcmToken: String | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Projects/BKData/Sources/Interface/Storage/PushTokenProvider.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| public protocol PushTokenProvider { | ||
| var fcmToken: String? { get } | ||
| var isSyncNeeded: Bool? { get } | ||
| func clearCache() | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/Projects/BKData/Sources/Interface/Storage/PushTokenStore.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKDomain | ||
| import Combine | ||
|
|
||
| public protocol PushTokenStore { | ||
| func save( | ||
| fcmToken: String | ||
| ) -> AnyPublisher<Void, TokenError> | ||
|
|
||
| func resetSyncNeeded() -> AnyPublisher<Void, TokenError> | ||
|
|
||
| func clear() -> AnyPublisher<Void, TokenError> | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/Projects/BKData/Sources/Repository/DefaultNotificationRepository.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKCore | ||
| import BKDomain | ||
| import Combine | ||
|
|
||
| public struct DefaultNotificationRepository: NotificationRepository { | ||
| private let networkProvider: NetworkProvider | ||
|
|
||
| public init(networkProvider: NetworkProvider) { | ||
| self.networkProvider = networkProvider | ||
| } | ||
|
|
||
| public func upsertFCMToken( | ||
| fcmToken: String | ||
| ) -> AnyPublisher<Void, DomainError> { | ||
| networkProvider.request( | ||
| target: UserAPI.upsertFCMToken(fcmToken: fcmToken), | ||
| type: UserProfileResponseDTO.self | ||
| ) | ||
| .debugError(logger: AppLogger.network) | ||
| .mapError { $0.toDomainError() } | ||
| .map { _ in } | ||
| .eraseToAnyPublisher() | ||
| } | ||
|
|
||
| public func upsertNotificationSettings( | ||
| notificationSettings: Bool | ||
| ) -> AnyPublisher<Bool, DomainError> { | ||
| networkProvider.request( | ||
| target: UserAPI.upsertNotificationSettings( | ||
| notificationEnabled: notificationSettings | ||
| ), | ||
| type: UserProfileResponseDTO.self | ||
| ) | ||
| .debugError(logger: AppLogger.network) | ||
| .mapError { $0.toDomainError() } | ||
| .map { $0.notificationEnabled } | ||
| .eraseToAnyPublisher() | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/Projects/BKData/Sources/Repository/DefaultPushTokenRepository.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKCore | ||
| import BKDomain | ||
| import Combine | ||
|
|
||
| public struct DefaultPushTokenRepository: PushTokenRepository { | ||
| private let pushTokenProvider: PushTokenProvider | ||
| private let pushTokenStore: PushTokenStore | ||
|
|
||
| public init( | ||
| pushTokenProvider: PushTokenProvider, | ||
| pushTokenStore: PushTokenStore | ||
| ) { | ||
| self.pushTokenProvider = pushTokenProvider | ||
| self.pushTokenStore = pushTokenStore | ||
| } | ||
|
|
||
| public func getFCMToken() -> String? { | ||
| return pushTokenProvider.fcmToken | ||
| } | ||
|
|
||
| public func isSyncNeeded() -> Bool { | ||
| return pushTokenProvider.isSyncNeeded ?? false | ||
| } | ||
|
|
||
| public func resetSyncNeeded() -> AnyPublisher<Void, DomainError> { | ||
| return pushTokenStore | ||
| .resetSyncNeeded() | ||
| .map { _ in | ||
| self.pushTokenProvider.clearCache() | ||
| } | ||
| .mapError { error in | ||
| Log.error("Failed to reset isSyncNeeded flag: \(error)", logger: AppLogger.storage) | ||
| return .clientError | ||
| } | ||
| .eraseToAnyPublisher() | ||
| } | ||
|
|
||
| public func clearCache() { | ||
| pushTokenProvider.clearCache() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,5 @@ public enum DomainError: Error, Equatable { | |
| case clientError | ||
| case internalServerError | ||
| case timeout | ||
| case unknown | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
src/Projects/BKDomain/Sources/Interface/Repository/NotificationRepository.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import Combine | ||
|
|
||
| public protocol NotificationRepository { | ||
| func upsertFCMToken( | ||
| fcmToken: String | ||
| ) -> AnyPublisher<Void, DomainError> | ||
|
|
||
| func upsertNotificationSettings( | ||
| notificationSettings: Bool | ||
| ) -> AnyPublisher<Bool, DomainError> | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/Projects/BKDomain/Sources/Interface/Repository/PushTokenRepository.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import Combine | ||
|
|
||
| public protocol PushTokenRepository { | ||
| func getFCMToken() -> String? | ||
| func isSyncNeeded() -> Bool | ||
| func resetSyncNeeded() -> AnyPublisher<Void, DomainError> | ||
| func clearCache() | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/Projects/BKDomain/Sources/Interface/Usecase/SyncFCMTokenUseCase.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import Combine | ||
| import Foundation | ||
|
|
||
| /// FCM 토큰이 동기화가 필요한 경우 서버에 업데이트합니다. | ||
| /// isSyncNeeded 플래그를 확인하고, 필요시 서버에 전송하며, 성공 시 플래그를 리셋합니다. | ||
| public protocol SyncFCMTokenUseCase { | ||
| func execute() -> AnyPublisher<Void, DomainError> | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/Projects/BKDomain/Sources/Interface/Usecase/UpdateNotificationSettingsUseCase.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import Combine | ||
| import Foundation | ||
|
|
||
| /// 알림 설정을 서버에 업데이트합니다. | ||
| public protocol UpdateNotificationSettingsUseCase { | ||
| func execute(isEnabled: Bool) -> AnyPublisher<Bool, DomainError> | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/Projects/BKDomain/Sources/UseCase/DefaultSyncFCMTokenUseCase.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKCore | ||
| import Combine | ||
| import Foundation | ||
|
|
||
| public struct DefaultSyncFCMTokenUseCase: SyncFCMTokenUseCase { | ||
| private let pushTokenRepository: PushTokenRepository | ||
| private let notificationRepository: NotificationRepository | ||
|
|
||
| public init( | ||
| pushTokenRepository: PushTokenRepository, | ||
| notificationRepository: NotificationRepository | ||
| ) { | ||
| self.pushTokenRepository = pushTokenRepository | ||
| self.notificationRepository = notificationRepository | ||
| } | ||
|
|
||
| public func execute() -> AnyPublisher<Void, DomainError> { | ||
| guard pushTokenRepository.isSyncNeeded() else { | ||
| return Just(()) | ||
| .setFailureType(to: DomainError.self) | ||
| .eraseToAnyPublisher() | ||
| } | ||
|
|
||
| guard let fcmToken = pushTokenRepository.getFCMToken() else { | ||
| return Just(()) | ||
| .setFailureType(to: DomainError.self) | ||
| .eraseToAnyPublisher() | ||
| } | ||
|
|
||
| return notificationRepository | ||
| .upsertFCMToken(fcmToken: fcmToken) | ||
| .debugError(logger: AppLogger.network) | ||
| .flatMap { _ -> AnyPublisher<Void, DomainError> in | ||
| return self.pushTokenRepository.resetSyncNeeded() | ||
| } | ||
| .eraseToAnyPublisher() | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍