-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushNotificationRepositoryImpl.swift
More file actions
60 lines (51 loc) · 1.88 KB
/
PushNotificationRepositoryImpl.swift
File metadata and controls
60 lines (51 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// PushNotificationRepositoryImpl.swift
// DevLog
//
// Created by 최윤진 on 1/18/26.
//
import Foundation
final class PushNotificationRepositoryImpl: PushNotificationRepository {
private let service: PushNotificationService
init(pushNotificationService: PushNotificationService) {
self.service = pushNotificationService
}
/// 푸시 알림 On/Off 설정
func fetchPushNotificationEnabled() async throws -> Bool {
return try await service.fetchPushNotificationEnabled()
}
/// 푸시 알림 시간 설정
func fetchPushNotificationTime() async throws -> DateComponents {
return try await service.fetchPushNotificationTime()
}
/// 푸시 알림 설정 업데이트
func updatePushNotificationSettings(_ settings: PushNotificationSettings) async throws {
try await service.updatePushNotificationSettings(
isEnabled: settings.isEnabled, components: settings.scheduledTime
)
}
/// 푸시 알림 기록 요청
func requestNotifications() async throws -> [PushNotification] {
try await service.requestNotifications()
.compactMap { dto in
dto.id.map { id in
PushNotification(
id: id,
title: dto.title,
body: dto.body,
receivedAt: dto.receivedAt.dateValue(),
isRead: dto.isRead,
todoID: dto.todoID
)
}
}
}
// 푸시 알림 기록 삭제
func deleteNotification(_ notificationID: String) async throws {
try await service.deleteNotification(notificationID)
}
// 푸시 알림 읽음/안읽음 토글
func toggleNotificationRead(_ todoID: String) async throws {
try await service.toggleNotificationRead(todoID)
}
}