From 2a89ccece6ea45363f50afe80aff17e6e3c0db29 Mon Sep 17 00:00:00 2001 From: Trey t Date: Sat, 22 Jan 2022 14:28:53 -0600 Subject: [PATCH] when saving onboarding data update notification time and title --- Shared/LocalNotification.swift | 5 +++-- Shared/Models/ContentModeViewModel.swift | 1 + Shared/views/SettingsView.swift | 6 ------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Shared/LocalNotification.swift b/Shared/LocalNotification.swift index d962843..c05177e 100644 --- a/Shared/LocalNotification.swift +++ b/Shared/LocalNotification.swift @@ -28,11 +28,12 @@ class LocalNotification { } } - public class func scheduleReminder(atTime time: Date) { + public class func scheduleReminder(atTime time: Date, withTitle title: String) { let _ = LocalNotification.createNotificationCategory() let notificationContent = UNMutableNotificationContent() - notificationContent.title = "How was your day?" + notificationContent.title = title + notificationContent.badge = NSNumber(value: 1) notificationContent.sound = .default notificationContent.categoryIdentifier = LocalNotification.categoryName diff --git a/Shared/Models/ContentModeViewModel.swift b/Shared/Models/ContentModeViewModel.swift index cb97ce0..5856d73 100644 --- a/Shared/Models/ContentModeViewModel.swift +++ b/Shared/Models/ContentModeViewModel.swift @@ -26,6 +26,7 @@ class ContentModeViewModel: ObservableObject { public func updateOnboardingData(onboardingData: OnboardingData) { self.savedOnboardingData = UserDefaultsStore.saveOnboarding(onboardingData: onboardingData) + LocalNotification.scheduleReminder(atTime: onboardingData.date, withTitle: onboardingData.title) } private func isMissingCurrentVote() -> Bool { diff --git a/Shared/views/SettingsView.swift b/Shared/views/SettingsView.swift index 670c7ff..922e96a 100644 --- a/Shared/views/SettingsView.swift +++ b/Shared/views/SettingsView.swift @@ -151,12 +151,6 @@ struct SettingsView: View { .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) } - private func updateNotificationTimes(toDate date: Date) { - LocalNotification.removeNotificaiton() - - LocalNotification.scheduleReminder(atTime: date) - } - private var showOnboardingButton: some View { ZStack { Color(UIColor.systemBackground)