alarmkit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAlarmKit
AlarmKit
Framework for scheduling alarms and countdown timers with custom UI, Live Activities integration, and focus/silent mode override. Prevents the most common mistakes: using the wrong authorization property name, omitting the Info.plist key, and forgetting the widget extension for countdown presentations.
一款用于调度闹钟和倒计时计时器的框架,支持自定义UI、Live Activities集成,以及专注/静音模式覆盖。可避免最常见的错误:使用错误的授权属性名称、遗漏Info.plist密钥、忘记用于倒计时展示的小组件扩展。
When This Skill Activates
技能适用场景
Use this skill when the user:
- Asks to add, fix, or review alarm or timer functionality
- Mentions AlarmKit, AlarmManager, or AlarmPresentation
- Wants to schedule one-time, repeating, or countdown alarms
- Asks about snooze, stop, or repeat buttons on alarm alerts
- Wants alarms to appear on Dynamic Island or Lock Screen (Live Activities)
- Mentions overriding Focus or silent mode for alarms
- Asks about AlarmAttributes or AlarmMetadata
当用户出现以下需求时,使用本技能:
- 请求添加、修复或审核闹钟或计时器功能
- 提及AlarmKit、AlarmManager或AlarmPresentation
- 需要调度一次性、重复或倒计时闹钟
- 询问闹钟提醒上的贪睡、停止或重复按钮
- 希望闹钟显示在Dynamic Island或锁屏(Live Activities)上
- 提及为闹钟覆盖专注模式或静音模式
- 询问AlarmAttributes或AlarmMetadata
Decision Tree
决策树
Choose the right reference file based on what the user needs:
What do you need?
|
+-- Schedule an alarm (one-time, repeating, or timer)
| --> scheduling.md
| +-- One-time alarm: Alarm.Schedule.relative + .repeats: .never
| +-- Repeating alarm: Alarm.Schedule.relative + .repeats: .weekly(weekdays)
| +-- Countdown timer: CountdownDuration (no schedule)
| +-- Authorization & Info.plist setup
| +-- Managing alarms: pause, resume, cancel
|
+-- Customize alarm UI (alert, countdown, paused screens)
| --> presentation.md
| +-- AlarmPresentation.Alert: title, stop, snooze/repeat buttons
| +-- AlarmPresentation.Countdown: title, pause button
| +-- AlarmPresentation.Paused: title, resume button
| +-- Custom buttons with AlarmButton
| +-- Tint color and metadata via AlarmAttributes
|
+-- Show alarm on Dynamic Island / Lock Screen
--> live-activities.md
+-- Widget extension with ActivityConfiguration
+-- AlarmAttributes conformance
+-- Custom AlarmMetadata protocol根据用户需求选择合适的参考文档:
What do you need?
|
+-- Schedule an alarm (one-time, repeating, or timer)
| --> scheduling.md
| +-- One-time alarm: Alarm.Schedule.relative + .repeats: .never
| +-- Repeating alarm: Alarm.Schedule.relative + .repeats: .weekly(weekdays)
| +-- Countdown timer: CountdownDuration (no schedule)
| +-- Authorization & Info.plist setup
| +-- Managing alarms: pause, resume, cancel
|
+-- Customize alarm UI (alert, countdown, paused screens)
| --> presentation.md
| +-- AlarmPresentation.Alert: title, stop, snooze/repeat buttons
| +-- AlarmPresentation.Countdown: title, pause button
| +-- AlarmPresentation.Paused: title, resume button
| +-- Custom buttons with AlarmButton
| +-- Tint color and metadata via AlarmAttributes
|
+-- Show alarm on Dynamic Island / Lock Screen
--> live-activities.md
+-- Widget extension with ActivityConfiguration
+-- AlarmAttributes conformance
+-- Custom AlarmMetadata protocolAPI Availability
API兼容性
| API | Minimum Version | Reference |
|---|---|---|
| iOS 18 | scheduling.md |
| iOS 18 | scheduling.md |
| iOS 18 | presentation.md |
| iOS 18 | live-activities.md |
| iOS 18 | live-activities.md |
| iOS 18 | presentation.md |
| iOS 18 | scheduling.md |
| iOS 18 | scheduling.md |
| iOS 18 | scheduling.md |
| API | 最低版本 | 参考文档 |
|---|---|---|
| iOS 18 | scheduling.md |
| iOS 18 | scheduling.md |
| iOS 18 | presentation.md |
| iOS 18 | live-activities.md |
| iOS 18 | live-activities.md |
| iOS 18 | presentation.md |
| iOS 18 | scheduling.md |
| iOS 18 | scheduling.md |
| iOS 18 | scheduling.md |
Top Mistakes -- Quick Reference
常见错误速查
| # | Mistake | Fix | Details |
|---|---|---|---|
| 1 | Using | The property is | scheduling.md |
| 2 | Forgetting | Add the key with a user-facing string before calling | scheduling.md |
| 3 | Creating countdown timer with a schedule | Timers use | scheduling.md |
| 4 | Missing widget extension for countdown presentations | Countdown and paused UI requires an | live-activities.md |
| 5 | Not persisting alarm UUIDs | Store the | scheduling.md |
| 6 | Not observing | Use the | scheduling.md |
| 序号 | 错误 | 修复方案 | 详情参考 |
|---|---|---|---|
| 1 | 使用 | 属性应为 | scheduling.md |
| 2 | 未在Info.plist中添加 | 在调用 | scheduling.md |
| 3 | 为倒计时计时器设置调度配置 | 计时器仅使用 | scheduling.md |
| 4 | 缺少用于倒计时展示的小组件扩展 | 倒计时和暂停UI需要 | live-activities.md |
| 5 | 未持久化闹钟UUID | 存储 | scheduling.md |
| 6 | 未监听 | 使用 | scheduling.md |
Review Checklist
审核清单
When reviewing AlarmKit code, verify:
- Info.plist -- is present with a meaningful description
NSAlarmKitUsageDescription - Authorization -- is called before scheduling; denial is handled gracefully
requestAuthorization() - Correct property -- uses , not
.authorizationState.authorizationStatus - Alarm ID persistence -- alarm UUIDs are stored (e.g., UserDefaults, SwiftData) for later management
- State observation -- async sequence is used to keep UI in sync
alarmUpdates - Widget extension -- exists if countdown or paused presentations are used
- Error handling -- ,
schedule(),pause(),resume()calls handle errorscancel() - System limits -- code accounts for the system limit on number of active alarms
- Real device testing -- alarms are tested on physical devices, not just Simulator
审核AlarmKit代码时,请验证:
- Info.plist——已添加且说明有意义
NSAlarmKitUsageDescription - 授权——调度前已调用;已优雅处理授权拒绝情况
requestAuthorization() - 属性正确性——使用而非
.authorizationState.authorizationStatus - 闹钟ID持久化——已存储闹钟UUID(如UserDefaults、SwiftData)以便后续管理
- 状态监听——已使用异步序列保持UI与状态同步
alarmUpdates - 小组件扩展——若使用倒计时或暂停展示则已存在该扩展
- 错误处理——、
schedule()、pause()、resume()调用已处理错误cancel() - 系统限制——代码已考虑系统对活跃闹钟数量的限制
- 真机测试——已在物理设备上测试闹钟功能,而非仅用模拟器
Reference Files
参考文档
| File | Content |
|---|---|
| scheduling.md | Authorization, one-time/repeating/timer creation, managing alarms, observing updates |
| presentation.md | Alert, countdown, paused UI customization, buttons, tint color |
| live-activities.md | Widget extension, AlarmAttributes, AlarmMetadata, Dynamic Island |
| 文件 | 内容 |
|---|---|
| scheduling.md | 授权、一次性/重复/计时器创建、闹钟管理、监听更新 |
| presentation.md | 提醒、倒计时、暂停UI自定义、按钮、色调 |
| live-activities.md | 小组件扩展、AlarmAttributes、AlarmMetadata、Dynamic Island |