SuperAPI AI 工具集

alarmkit

通用与其它

查看项目

更新于 10-15 21:12

技能介绍

用途:在 iOS/iPadOS 应用中调度醒目的闹钟与倒计时,触发时通过系统 UI 在锁屏、灵动岛、StandBy 和配对的 Apple Watch 上呈现,可突破专注模式与静音模式。要求 iOS 26+ / iPadOS 26+。

主要能力:使用 AlarmManager 请求授权并调度 .alarm(指定时刻,支持 .fixed 或 .relative 及 .never/.weekly 重复)或 .timer(按时长触发,始终显示倒计时)。通过 AlarmPresentation 配置 alert、countdown、paused 状态,用 AlarmAttributes<Metadata> 定义 Live Activity 静态数据。闹钟状态包括 scheduled、countdown、paused、alerting,可用 cancel(id:)、pause(id:)、resume(id:)、stop(id:)、countdown(id:) 操作,并通过 alarmUpdates 观察变化。

使用方式:在 Info.plist 添加 NSAlarmKitUsageDescription,调用 AlarmManager.shared.requestAuthorization() 获取授权,未授权时展示恢复 UI 而非调度。用 AlarmManager.shared.schedule(id:configuration:) 调度。倒计时/暂停状态需添加 Widget Extension,其 ActivityConfiguration 使用与调度时相同的 AlarmAttributes<Metadata> 类型。

限制:触发告警 UI 由系统管理,自定义 UI 仅限倒计时与暂停的 Live Activity 状态;metadata 应保持轻量;标准 Stop/Snooze 无需提供 intent,仅在需要清理或自定义行为时提供。缺少 Widget Extension 时闹钟可能被意外关闭或无法告警。具体价格、平台支持范围等资料暂未提供。