Skip to content

Getting Started

Terminal window
bun add @capgo/capacitor-alarm
bunx cap sync
import { CapgoAlarm } from '@capgo/capacitor-alarm';

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+).

import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.createAlarm({
hour: 7,
minute: 30,
label: 'Wake up',
skipUi: false,
vibrate: true
});
console.log('Alarm created:', result.success);

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

import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();
if (result.success) {
console.log('Alarms UI opened');
}

Get information about the OS and capabilities.

import { CapgoAlarm } from '@capgo/capacitor-alarm';
const info = await CapgoAlarm.getOSInfo();
console.log('Platform:', info.platform);
console.log('Supports native alarms:', info.supportsNativeAlarms);
if (info.platform === 'android') {
console.log('Can schedule exact alarms:', info.canScheduleExactAlarms);
}

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

import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.requestPermissions({ exactAlarm: true });
if (result.granted) {
console.log('Permissions granted');
} else {
console.log('Permissions denied');
}

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

import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();
console.log('AlarmKit allowed?', status.details?.alarmKit);

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.

import { CapgoAlarm } from '@capgo/capacitor-alarm';
const { alarms } = await CapgoAlarm.getAlarms();
console.log('Scheduled alarms:', alarms);
alarms.forEach(alarm => {
console.log(`Alarm ${alarm.id}: ${alarm.hour}:${alarm.minute} - ${alarm.label}`);
});

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

export interface NativeAlarmCreateOptions {
/** Hour of day in 24h format (0-23) */
hour: number;
/** Minute of hour (0-59) */
minute: number;
/** Optional label for the alarm */
label?: string;
/** Android only: attempt to skip UI if possible */
skipUi?: boolean;
/** Android only: set alarm to vibrate */
vibrate?: boolean;
}

Result of a native action.

export interface NativeActionResult {
/** Whether the action was successful */
success: boolean;
/** Optional message with additional information */
message?: string;
}

Returned info about current OS and capabilities.

export interface OSInfo {
/** Platform identifier: 'ios' | 'android' | 'web' */
platform: string;
/** OS version string */
version: string;
/** Whether the platform exposes a native alarm app integration */
supportsNativeAlarms: boolean;
/** Whether scheduling local notifications is supported */
supportsScheduledNotifications: boolean;
/** Android only: whether exact alarms are allowed */
canScheduleExactAlarms?: boolean;
}

Result of a permissions request.

export interface PermissionResult {
/** Overall grant for requested scope */
granted: boolean;
/** Optional details by permission key */
details?: Record<string, boolean>;
/** Optional human readable diagnostic */
message?: string;
}

Information about a scheduled alarm.

export interface AlarmInfo {
/** Unique identifier for the alarm */
id: string;
/** Hour of day in 24h format (0-23) */
hour: number;
/** Minute of hour (0-59) */
minute: number;
/** Optional label for the alarm */
label?: string;
/** Whether the alarm is enabled */
enabled?: boolean;
}

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.