Created
July 28, 2025 19:43
-
-
Save jacobsapps/c03de09730b6834382e8ea0a9e5843d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func scheduleAlarm(at schedule: Alarm.Schedule) async throws { | |
// primary action button, that stops the alarm | |
let stopButton = AlarmButton( | |
text: "Mmm, Elvanse", | |
textColor: .white, | |
systemImageName: "checkmark.circle" | |
) | |
// what gets presented by the alarm - wraps the button | |
let alertPresentation = AlarmPresentation.Alert( | |
title: "Take your meds!", | |
stopButton: stopButton | |
) | |
// other customisation - wraps the presentation | |
let attributes = AlarmAttributes( | |
presentation: AlarmPresentation(alert: alertPresentation), | |
metadata: ADHDMetadata(), | |
tintColor: Color.orange | |
) | |
// alarm settings - wraps schedule and attributes | |
let alarmConfiguration = AlarmManager.AlarmConfiguration<ADHDMetadata> | |
.alarm( | |
schedule: schedule, | |
attributes: attributes | |
) | |
// finally schedules the alarm | |
_ = try await AlarmManager.shared.schedule( | |
id: UUID(), | |
configuration: alarmConfiguration | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment