Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/88c40a4145fafe5e1dcc810d3dfb0e6d to your computer and use it in GitHub Desktop.
Save jacobsapps/88c40a4145fafe5e1dcc810d3dfb0e6d to your computer and use it in GitHub Desktop.
func scheduleCountdownAlarm() async throws {
let stopButton = AlarmButton(
text: "Mmm, Elvanse",
textColor: .white,
systemImageName: "checkmark.seal.fill"
)
let repeatButton = AlarmButton(
text: "I forgot",
textColor: .red,
systemImageName: "repeat.circle.fill"
)
let alertPresentation = AlarmPresentation.Alert(
title: "Take your meds!",
stopButton: stopButton,
secondaryButton: repeatButton,
secondaryButtonBehavior: .countdown
)
let attributes = AlarmAttributes(
presentation: AlarmPresentation(alert: alertPresentation),
metadata: ADHDMetadata(),
tintColor: Color.orange
)
let countdownConfiguration = AlarmManager.AlarmConfiguration<ADHDMetadata>
.init(
countdownDuration: Alarm.CountdownDuration(preAlert: 10, postAlert: 10),
attributes: attributes
)
_ = try await AlarmManager.shared.schedule(id: UUID(), configuration: countdownConfiguration)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment