when saving onboarding data update notification time and title

This commit is contained in:
Trey t
2022-01-22 14:28:53 -06:00
parent e1839d54ae
commit 2a89ccece6
3 changed files with 4 additions and 8 deletions

View File

@@ -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 _ = LocalNotification.createNotificationCategory()
let notificationContent = UNMutableNotificationContent() let notificationContent = UNMutableNotificationContent()
notificationContent.title = "How was your day?" notificationContent.title = title
notificationContent.badge = NSNumber(value: 1) notificationContent.badge = NSNumber(value: 1)
notificationContent.sound = .default notificationContent.sound = .default
notificationContent.categoryIdentifier = LocalNotification.categoryName notificationContent.categoryIdentifier = LocalNotification.categoryName

View File

@@ -26,6 +26,7 @@ class ContentModeViewModel: ObservableObject {
public func updateOnboardingData(onboardingData: OnboardingData) { public func updateOnboardingData(onboardingData: OnboardingData) {
self.savedOnboardingData = UserDefaultsStore.saveOnboarding(onboardingData: onboardingData) self.savedOnboardingData = UserDefaultsStore.saveOnboarding(onboardingData: onboardingData)
LocalNotification.scheduleReminder(atTime: onboardingData.date, withTitle: onboardingData.title)
} }
private func isMissingCurrentVote() -> Bool { private func isMissingCurrentVote() -> Bool {

View File

@@ -151,12 +151,6 @@ struct SettingsView: View {
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
} }
private func updateNotificationTimes(toDate date: Date) {
LocalNotification.removeNotificaiton()
LocalNotification.scheduleReminder(atTime: date)
}
private var showOnboardingButton: some View { private var showOnboardingButton: some View {
ZStack { ZStack {
Color(UIColor.systemBackground) Color(UIColor.systemBackground)