Skip to content

Commit

Permalink
feat #47: PushNotice 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seungyooooong committed Feb 20, 2025
1 parent a0af06a commit 40dfa6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 0 additions & 1 deletion dogether/Presentation/View/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ extension MainViewController: UIScrollViewDelegate {
extension MainViewController {
@objc private func handlePushNotification(_ notification: Notification) {
guard let notificationType = notification.userInfo?["type"] as? String,
notificationType == PushNoticeTypes.certification.rawValue ||
notificationType == PushNoticeTypes.review.rawValue else { return }

if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
Expand Down
17 changes: 16 additions & 1 deletion dogether/Utility/Manager/PushNoticeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,29 @@ final class PushNoticeManager: NSObject, UNUserNotificationCenterDelegate {

private func handleNotification(notification: UNNotification) {
let userInfo = notification.request.content.userInfo
if let notificationType = userInfo["type"] as? String {
guard let notificationTypeString = userInfo["type"] as? String,
let notificationType = PushNoticeTypes(rawValue: notificationTypeString) else { return }
switch notificationType {
case .certification:
// TODO: 이미 모달 화면인 경우를 고려해 pushNotificationReceived로 넘기고 ModalityViewController에서 추후 컨트롤
Task { @MainActor in
let response: GetReviewsResponse = try await NetworkManager.shared.request(TodoCertificationsRouter.getReviews)
if response.dailyTodoCertifications.count > 0 {
Task { @MainActor in
ModalityManager.shared.show(reviews: response.dailyTodoCertifications)
}
}
}
case .review:
DispatchQueue.main.async {
NotificationCenter.default.post(
name: PushNoticeManager.pushNotificationReceived,
object: nil,
userInfo: ["type": notificationType]
)
}
default:
return
}
}

Expand Down

0 comments on commit 40dfa6d

Please sign in to comment.