Building a real alarm app on AlarmKit: notes from the field

AlarmKit arrived in iOS 26, and with it, alarm apps no longer have to be notification apps in disguise. A third-party alarm can now do what the Clock app’s alarm does, without a special entitlement. It can break through Silent mode and Focus, take over the Lock Screen, and show in the Dynamic Island. So I built Wakeprint on top of it, on my own. In this post I’ll walk you through what surprised me on real devices, and how I test something that does its job while the phone is locked.

All the code below is adapted from the shipping app and trimmed for length.

Why AlarmKit?

Before iOS 26, you built an “alarm app” out of local notifications. Each one had a sound shorter than 30 seconds, and you hoped the user hadn’t switched on Silent mode.

AlarmKit gives you a system alarm instead. The system owns the schedule, the ringing, the snooze countdown and the Lock Screen presentation. Your app supplies the configuration and some App Intents.

So what’s the catch? Control.

You don’t play the sound, and you can’t set the volume. Alarm state lives in a system daemon. You can query it (alarms) or observe it (alarmUpdates), but you can’t change it directly.

The permission flow

Everything starts in Info.plist, where you need an NSAlarmKitUsageDescription string. Mine says what the permission is for, in plain language: “Wakeprint needs this permission to ring your alarms.”

Two things are worth knowing here. First, the prompt can appear without you asking for it. The documentation for AuthorizationState.notDetermined says that scheduling an alarm while the state is undetermined triggers the system prompt anyway. If you want to show your own explainer screen first, check the state yourself before your first schedule call.

Second, requestAuthorization() returns right away, with no prompt, if the user has already decided. Getting a result doesn’t mean the prompt was shown. That’s why I record the outcome only if the state was undetermined before the call:

let wasUndetermined = AlarmManager.shared.authorizationState == .notDetermined
let state = try await AlarmManager.shared.requestAuthorization()
if wasUndetermined {
    // The person actually answered the system prompt; record `state`.
}

If permission is denied, I still save the first alarm, just switched off, with a way to get to Settings. When the app comes back to the foreground, a reconciliation pass re-reads the state and arms whatever should be armed.

While access stays off, the app’s Today screen shows the two steps to the Alarms switch in Settings, and an alarm that’s on says “Won’t ring · access off” there instead of counting down. When access comes back, that pass first cancels the alarms AlarmKit held on to and schedules them again: on iOS 27.2, the first schedule or cancel call after the lapse could ring a missed alarm late.

Scheduling and repeating

Repeating alarms are the easy part: .relative with .weekly([Locale.Weekday]). Apple’s docs say .relative follows the device’s current time zone, and recommend it for wake-up alarms.

One-off alarms are trickier. Here’s how I pick the schedule:

let time = Alarm.Schedule.Relative.Time(hour: alarm.hour, minute: alarm.minute)
let schedule: Alarm.Schedule = alarm.weekdays.isEmpty
    ? (isDueSoon ? .fixed(fireDate) : .relative(.init(time: time, repeats: .never)))
    : .relative(.init(time: time, repeats: .weekly(weekdays)))

Why isDueSoon? It comes from a report on the Apple Developer Forums (thread 797618). Scheduled at 12:00, a relative one-off for 12:02 landed on the next day, while one for 12:05 rang. The report didn’t give an exact threshold.

So if a one-off is due within 15 minutes, I schedule it with a fixed date (.fixed) instead.

The timing of that choice matters too. I choose the schedule after the slow work (rendering audio files), right before schedule(id:configuration:). That way, the “now” I compare against is still current.

Every AlarmKit call in my app goes through one protocol, AlarmScheduling. The production type wraps AlarmManager.shared, and tests use fakes that simulate failure, delay and races. This turned out to be my best decision, since almost every AlarmKit bug I hit was an ordering problem.

Then there’s the problem of uncertain outcomes. AlarmManager talks to a system daemon, and I assume a call can fail on my side after the daemon has already committed it. An error alone doesn’t tell me the alarm is missing. If the alarm wasn’t registered before the call and is registered after it, I count the call as a success:

let wasRegistered = try? AlarmManager.shared.alarms.contains { $0.id == id }
do {
    _ = try await AlarmManager.shared.schedule(id: id, configuration: configuration)
} catch {
    let isRegistered = (try? AlarmManager.shared.alarms.contains { $0.id == id }) == true
    guard wasRegistered == false, isRegistered else { throw error }
}

I handle stop(id:) the same way. If the alarm is no longer alerting after an error, I count the Stop as a success.

While you’re checking state, remember that Alarm.state is a snapshot. Per the documentation, it’s taken when you fetched the alarm, and it doesn’t update, so read it again just before you act on it.

One last detail for edits: stopping an alarm and removing its schedule are separate calls. To edit or delete a ringing alarm, I call stop(id:) first, then cancel(id:) only if the alarm is still registered, since a one-off may be gone after the stop.

Lock Screen and Live Activity

In AlarmKit, an alarm is presented as a Live Activity, but you only draw part of it. The ringing alert, with its Stop and secondary buttons, is a system template built from AlarmPresentation.Alert. Your widget extension draws the rest, with ActivityConfiguration(for: AlarmAttributes<YourMetadata>.self).

What’s “the rest”? In Apple’s sample, it’s the non-alerting states: countdown and paused. The widget draws them on the Lock Screen, in the Dynamic Island and in StandBy.

I put an ID and a role in my AlarmMetadata. The role says whether it’s the user’s alarm or a rescue countdown (more on rescue alarms below). That way one widget can draw the right content for each state, using context.state.mode (.alert, .countdown, .paused).

How you get the Stop control depends on the iOS version. On iOS 26.1 and later, AlarmPresentation.Alert(title:secondaryButton:secondaryButtonBehavior:) provides it for you. On 26.0, I still pass an explicit stopButton.

For snooze, stick with the system’s own path: .countdown with a postAlert duration. I avoid a custom action there, because the switch from ringing to snoozed could end up triggering the primary Stop intent. I haven’t reproduced this on a device, so consider it a warning, not a confirmed bug.

The Stop button runs your intent. Mine runs in the background on purpose, because stopping an alarm shouldn’t unlock the phone or open the app:

struct StopAlarmIntent: LiveActivityIntent, AudioPlaybackIntent {
    static let title: LocalizedStringResource = "Stop Alarm"
    static var supportedModes: IntentModes { [.background] }
    @Parameter(title: "Alarm ID") var alarmID: String

    init() { alarmID = "" }
    init(alarmID: UUID) { self.alarmID = alarmID.uuidString }

    func perform() async throws -> some IntentResult {
        // Record the Stop, maybe arm a rescue alarm; never open the UI.
        return .result()
    }
}

The same intent can also run while your app is in the foreground. That’s why I check UIApplication.shared.applicationState: a Stop pressed while someone is already using the app says nothing new about whether they’re awake.

There’s a side effect here: the intent can launch your app in the background, and that launch runs whatever your app normally does when it starts.

Picture two alarms ringing at the same time. You stop one from the Lock Screen, and the app launches in the background. A routine “find missed alarms” pass can then see a Stop after the other alarm’s fire time, and count that alarm as handled. And if your cancel path stops a ringing alarm first, that other alarm goes silent without anyone noticing.

You can guard against this in two ways. During a background launch, don’t let housekeeping touch recent alerts. And only let a Stop mark another alarm as handled if the stopped alarm is the later one.

More generally, check every code path a background Stop can reach.

Volume

You can’t set the volume, so which volume does the alarm use? On iOS 26, an Apple DTS engineer confirmed on the forums (thread 813519) that AlarmKit alarms play at the system ringer volume. That means someone who keeps their ringer low gets a quiet alarm.

iOS 27 adds a separate volume slider for alarms and timers in Settings, and I wanted to know which control my alarm follows now. On a test iPhone running iOS 27.0.1, I set the alarm slider high and the ringer low, then the reverse. In the system logs, the alarm’s audio route took its volume from the alarm category (0.75, then 0.3125), and the ringer value was marked “ignored”.

So on 27.0.1, a third-party AlarmKit alarm follows the new alarm slider, not the ringer. Some caveats, though: I only tested one device model, two rings and the built-in speaker, and I didn’t compare it with the Clock app.

As for the sound itself, you reference custom sounds by file name with AlertConfiguration.AlertSound.named(...), and I keep the files in Library/Sounds. On both the iOS 26.4 simulator and an iOS 27 device, the system logs show my alarm configured like this: shouldRepeat = YES, shouldIgnoreRingerSwitch = YES, maximumDuration = 900.

On iOS 26.1 and later, the file loops until the alarm is stopped. (Developers reported that iOS 26.0 played a custom sound only once.) That matters if you build effects into your sound files. I render a “gradual volume” version of each sound as a 29-second file with a fade-in:

let gain = 0.06 + 0.94 * progress * progress

Because the file loops, the fade starts over every 29 seconds: the sound drops back to 6% gain (about −24 dB) and climbs again. If you bake an envelope into an alarm sound, keep it short, or make sure the loop point sounds fine.

A rescue alarm for falling back asleep

What if someone stops the alarm and falls back asleep? Wakeprint has an opt-in feature for exactly that, called Wake Rescue. If you stop the alarm on the Lock Screen or from the banner and don’t tap “I’m up”, a rescue alarm with a different sound rings 5, 10 or 15 minutes later.

In Wake Rescue’s repeat mode, stopping a rescue alarm arms the next one, until you tap “I’m up” or one hour has passed since the first Stop.

Each rescue alarm is a timer, not a scheduled alarm. With no schedule and a preAlert countdown, the system runs the countdown, and your widget extension draws it on the Lock Screen and in the Dynamic Island.

Don’t skip that extension. AlarmKit expects one for any countdown, and Apple warns that without it, the system may dismiss the alarm without alerting.

My widget adds an “I’m up” button to the countdown. Here’s how I configure a rescue alarm:

// RescueStopIntent is built like StopAlarmIntent above,
// with init(parentAlarmID: UUID, rescueAlarmID: UUID).
let remaining = max(1, fireDate.timeIntervalSince(.now))
let configuration = AlarmManager.AlarmConfiguration(
    countdownDuration: Alarm.CountdownDuration(preAlert: remaining, postAlert: nil),
    schedule: nil,
    attributes: attributes,
    stopIntent: RescueStopIntent(parentAlarmID: parentID, rescueAlarmID: rescueID),
    sound: .named(fileName))

Three rules made the chain reliable.

First, I save the rescue alarm’s ID to disk before calling schedule. That way, if the background process is suspended right after, the next foreground pass can still find it and cancel it.

Second, AlarmConfiguration isn’t Sendable, so I build a new one for each retry instead of reusing one after an await.

Third, I don’t start a rescue alarm if another of the user’s alarms is ringing, or is due before the rescue alarm would ring. A real alarm is the stronger fallback.

Testing

How do you test something that does its job while the phone is locked? Let’s start with the simulator.

In late October, the iOS 27.0 and 27.1 simulator runtimes denied AlarmKit authorization without showing a prompt. The log showed that mobiletimerd was missing the com.apple.springboard.CFUserNotification entitlement. The iOS 26.4 simulator works, so that’s where I run alarm, Live Activity and widget flows. Unit tests run on all three, and iOS 27 alarm flows run only on a real device.

Re-check this with every new Xcode release, because this kind of note goes stale fast.

On a real device, I keep test alarms silent: QA builds swap the sound of any test-labeled alarm for a silent file. That way, on-device test runs can happen at any hour without waking anyone. A UI-test runner plays the user: it waits for the alarm to ring and stops it on the Lock Screen.

Results come from the device’s system log (mobiletimerd, the tone player), not from a microphone. That’s on purpose. Under load, my Mac’s microphone missed 10 to 14 seconds of an 85-second recording, which made a normal ring look as if it stopped after 25 seconds.

The microphone wasn’t the only tool that misled me, so check your tools before you blame the app.

On iOS 27.2, a full-screen alarm hides the Lock Screen’s date view, so my lock detector reported “unlocked” on a locked phone. And on iOS 27, XCUITest’s adjust(toNormalizedSliderPosition:) didn’t set the new volume slider to the requested position. Now I use the hardware volume buttons instead, and read the value back.

Then there are time zones and daylight saving. On the device, my test runs change the phone’s time zone and date in Settings, then undo every change and check that it’s undone. My unit tests cover two hard cases.

The first is a time that doesn’t exist: 02:30 on 14 March 2027 in New York. Since AlarmKit doesn’t document what a relative alarm does with it, I schedule that morning’s alarm with a fixed date at 03:00, matching the time the app shows.

The second is travel. A one-off set for 07:00 in London rings in Istanbul at 07:00 local time, even though its stored date, 09:00 Istanbul time, hasn’t arrived yet. The trap: if you re-arm it from that stored date, it rings a second time the next morning.

What I learned

Looking back, the first lesson I’d pass on is simple: put AlarmKit behind a protocol on day one. Fakes reproduce ordering bugs on demand, and devices rarely do.

Next, assume every daemon call is “maybe done”, and check what’s registered before and after. For one-offs, pick .relative or .fixed deliberately, and make that choice as late as possible.

A background Stop is a full app launch, so audit what it runs.

Volume belongs to the system, and its behavior changed between iOS 26 and 27. Test on the versions your users run. And if you show a countdown, ship the widget extension that draws it.

Finally, budget time for real devices. Keep test alarms silent and labeled, and read the system log.

Wakeprint is an iPhone alarm app that gets to know your mornings. wakeprint.app

Download on the App Store