@capgo/capacitor-alarm

中文文档
8.1.14发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4.1万

Manage native alarm Capacitor plugin

原始使用文档
文档目录19 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor Alarm?
  4. Documentation
  5. Compatibility
  6. Install
  7. Requirements
  8. Permission checks
  9. API
  10. createAlarm(...)
  11. openAlarms()
  12. getOSInfo()
  13. requestPermissions(...)
  14. checkPermissions()
  15. getPluginVersion()
  16. getAlarms()
  17. cancelAlarm(...)
  18. Interfaces
  19. Type Aliases

@capgo/capacitor-alarm

Create real alarms in the system clock from your Capacitor app: AlarmKit on iOS 26 and later and the Alarm Clock intent on Android. Alarm and reminder apps get alarms that ring like the built-in clock.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-alarm in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-alarm to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-alarm for Capacitor apps

Key features

  • Native alarms: createAlarm() adds an alarm through AlarmKit on iOS 26 and later, or through the platform clock app on Android.
  • Alarm list: openAlarms() opens the system alarm UI where available.
  • Manage on iOS: getAlarms() and cancelAlarm() list and remove alarms created by your app on iOS 26 and later.
  • Capabilities: getOSInfo() reports what the current OS supports.
  • Permissions: checkPermissions() and requestPermissions(), including exact alarm access on Android.
  • Platforms: iOS and Android. Listing and cancelling alarms is iOS only. Not available on web.

Why Capacitor Alarm?

The only plugin implementing the latest native alarm APIs for both iOS and Android:

  • iOS 26+ AlarmKit - Full integration with Apple's new alarm framework
  • Android AlarmClock intents - Modern alarm management following OEM policies
  • Future-proof - Built on the newest platform APIs, not deprecated methods
  • Cross-platform - Consistent API across iOS and Android

Essential for alarm clock apps, reminder apps, medication trackers, and any app needing native system alarms.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/alarm/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-alarm` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-alarm
npx cap sync

Requirements

  • iOS: iOS 26+ only. This plugin relies on AlarmKit APIs and will report unsupported on earlier versions or when the framework is unavailable.
  • Android: Uses AlarmClock intents; behavior depends on the default Clock app and OEM policies.

Note: This plugin only exposes native alarm actions (create/open). It does not implement any custom in-app alarm scheduling/CRUD.

Permission checks

Use CapgoAlarm.checkPermissions() to query whether AlarmKit (iOS) or the platform clock integration (Android) is ready before prompting users. The method never opens system UI and returns a PermissionResult with details describing platform-specific states (for example, { alarmKit: true } on iOS or { exactAlarm: false } on Android 12+).

If your native runtime ships an older build of this plugin that predates the checkPermissions bridge, the JavaScript shim resolves with { granted: false, message: 'CapgoAlarm.checkPermissions is not implemented...' } so you can gracefully fall back to feature detection or request an update.

API

Capacitor Alarm Plugin interface for managing native OS alarms.

createAlarm(...)

createAlarm(options: NativeAlarmCreateOptions) => Promise<NativeActionResult>

Create a native OS alarm using the platform clock app. On Android this uses the Alarm Clock intent; on iOS this uses AlarmKit if available (iOS 16+).

ParamTypeDescription
optionsNativeAlarmCreateOptions- Options for creating the alarm

Returns: Promise<NativeActionResult>

Since: 1.0.0


openAlarms()

openAlarms() => Promise<NativeActionResult>

Open the platform's native alarm list UI, if available.

Returns: Promise<NativeActionResult>

Since: 1.0.0


getOSInfo()

getOSInfo() => Promise<OSInfo>

Get information about the OS and capabilities.

Returns: Promise<OSInfo>

Since: 1.0.0


requestPermissions(...)

requestPermissions(options?: { exactAlarm?: boolean | undefined; } | undefined) => Promise<PermissionResult>

Request relevant permissions for alarm usage on the platform. On Android, may route to settings for exact alarms.

ParamTypeDescription
options{ exactAlarm?: boolean; }- Optional parameters for the permission request

Returns: Promise<PermissionResult>

Since: 1.0.0


checkPermissions()

checkPermissions() => Promise<PermissionResult>

Check the current permission state for native alarm access without triggering UI. On iOS this reports AlarmKit readiness; on Android it reports capability details.

Returns: Promise<PermissionResult>

Since: 8.0.4


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version.

Returns: Promise<{ version: string; }>

Since: 1.0.0


getAlarms()

getAlarms() => Promise<{ alarms: AlarmInfo[]; message?: string; }>

Get a list of alarms scheduled by this app. On iOS 26+, returns alarms from AlarmKit. On Android, this is not supported as the system does not provide an API to query alarms.

Returns: Promise<{ alarms: AlarmInfo[]; message?: string; }>

Since: 1.1.0


cancelAlarm(...)

cancelAlarm(options: { id: string; }) => Promise<NativeActionResult>

Cancel a scheduled alarm by its ID. On iOS 26+, removes the alarm from AlarmKit. On Android/web, returns not supported.

ParamTypeDescription
options{ id: string; }- Options containing the alarm ID to cancel

Returns: Promise<NativeActionResult>

Since: 8.1.0


Interfaces

NativeActionResult

Result of a native action.

PropTypeDescription
successbooleanWhether the action was successful
messagestringOptional message with additional information
idstringOptional alarm ID (returned by createAlarm on iOS)

NativeAlarmCreateOptions

Options for creating a native OS alarm via the platform clock app.

PropTypeDescription
hournumberHour of day in 24h format (0-23)
minutenumberMinute of hour (0-59)
labelstringOptional label for the alarm
skipUibooleanAndroid only: attempt to skip UI if possible
vibratebooleanAndroid only: set alarm to vibrate

OSInfo

Returned info about current OS and capabilities.

PropTypeDescription
platformstringPlatform identifier: 'ios' | 'android' | 'web'
versionstringOS version string
supportsNativeAlarmsbooleanWhether the platform exposes a native alarm app integration
supportsScheduledNotificationsbooleanWhether scheduling local notifications is supported
canScheduleExactAlarmsbooleanAndroid only: whether exact alarms are allowed

PermissionResult

Result of a permissions request.

PropTypeDescription
grantedbooleanOverall grant for requested scope
detailsRecord<string, boolean>Optional details by permission key
messagestringOptional human readable diagnostic

AlarmInfo

Information about a scheduled alarm.

PropTypeDescription
idstringUnique identifier for the alarm
hournumberHour of day in 24h format (0-23). May be absent for alarms created outside this plugin.
minutenumberMinute of hour (0-59). May be absent for alarms created outside this plugin.
labelstringOptional label for the alarm
enabledbooleanWhether the alarm is enabled

Type Aliases

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

版本与发布记录

@capgo/capacitor-alarm 共发布 63 个版本,首次发布于 2025/09/16;过去 12 个月发布了 26 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.1.14latest2026/10/1525 天前
8.1.132026/10/1327 天前
8.1.122026/10/091 个月前
8.1.112026/10/081 个月前
8.1.102026/10/081 个月前
8.1.92026/09/161 个月前

关于 @capgo/capacitor-alarm 的常见问题

@capgo/capacitor-alarm 是什么?

Manage native alarm Capacitor plugin

如何安装 @capgo/capacitor-alarm?

在项目目录运行 npm install @capgo/capacitor-alarm,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-alarm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-alarm 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-alarm 可以商用吗?

@capgo/capacitor-alarm 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-alarm 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-alarm 在 2026/10/09 – 2026/11/07 这 30 天内被下载 40,839 次,日均约 1,361 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-alarm 还在维护吗?

最新版本 8.1.14 发布于 2026/10/15(25 天前);至今共发布 63 个版本,其中过去 12 个月发布了 26 个;首次发布于 2025/09/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。