Skip to content

Commit 710a498

Browse files
authored
Add alarms for notifications with due dates (#77)
I'm surprised this doesn't happen automatically but it seems that this is how Reminders.app makes notifications work.
1 parent 886a6a3 commit 710a498

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Sources/RemindersLibrary/CLI.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private struct ShowLists: ParsableCommand {
1919
private struct ShowAll: ParsableCommand {
2020
static let configuration = CommandConfiguration(
2121
abstract: "Print all reminders")
22-
22+
2323
@Flag(help: "Show completed items only")
2424
var onlyCompleted = false
2525

@@ -42,15 +42,15 @@ private struct ShowAll: ParsableCommand {
4242
"Cannot specify both --show-completed and --only-completed")
4343
}
4444
}
45-
45+
4646
func run() {
4747
var displayOptions = DisplayOptions.incomplete
4848
if self.onlyCompleted {
4949
displayOptions = .complete
5050
} else if self.includeCompleted {
5151
displayOptions = .all
5252
}
53-
53+
5454
reminders.showAllReminders(
5555
dueOn: self.dueDate, displayOptions: displayOptions, outputFormat: format)
5656
}
@@ -151,7 +151,7 @@ private struct Add: ParsableCommand {
151151
string: self.reminder.joined(separator: " "),
152152
notes: self.notes,
153153
toListNamed: self.listName,
154-
dueDate: self.dueDate,
154+
dueDateComponents: self.dueDate,
155155
priority: priority,
156156
outputFormat: format)
157157
}

Sources/RemindersLibrary/Reminders.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public final class Reminders {
305305
string: String,
306306
notes: String?,
307307
toListNamed name: String,
308-
dueDate: DateComponents?,
308+
dueDateComponents: DateComponents?,
309309
priority: Priority,
310310
outputFormat: OutputFormat)
311311
{
@@ -314,8 +314,11 @@ public final class Reminders {
314314
reminder.calendar = calendar
315315
reminder.title = string
316316
reminder.notes = notes
317-
reminder.dueDateComponents = dueDate
317+
reminder.dueDateComponents = dueDateComponents
318318
reminder.priority = Int(priority.value.rawValue)
319+
if let dueDate = dueDateComponents?.date {
320+
reminder.addAlarm(EKAlarm(absoluteDate: dueDate))
321+
}
319322

320323
do {
321324
try Store.save(reminder, commit: true)

0 commit comments

Comments
 (0)