Démarrage
Copiez un prompt de configuration avec les étapes d'installation et le guide Markdown complet pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-alarm`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/alarm/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installer
Section intitulée « Installer »bun add @capgo/capacitor-alarmbunx cap syncImporter
Section intitulée « Importer »import { CapgoAlarm } from '@capgo/capacitor-alarm';API Aperçu
Section intitulée « API Aperçu »createAlarm
Section intitulée « createAlarm »Créez un alarme natif du système en utilisant l'application horloge du système. Sur Android, cela utilise l'intent de l'alarme ; sur iOS, cela utilise AlarmKit si disponible (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);openAlarms
Section intitulée “openAlarms”Ouvrez la liste d'alarme native du système, si disponible.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();if (result.success) { console.log('Alarms UI opened');}getOSInfo
Section intitulée “getOSInfo”Obtenez des informations sur le système et ses capacités.
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);}requestPermissions
Section intitulée “requestPermissions”Demandez les permissions pertinentes pour l'utilisation des alarmes sur le système. Sur Android, cela peut rediriger vers les paramètres pour les alarmes exactes.
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');}checkPermissions
Section intitulée “checkPermissions”Vérifiez l'état de permission actuel pour l'accès à l'alarme native sans déclencher l'interface utilisateur.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();console.log('AlarmKit allowed?', status.details?.alarmKit);getAlarms
Section intitulée “getAlarms”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}`);});Référence de type
Section intitulée “Type Reference”NativeAlarmCreateOptions
Section intitulée “NativeAlarmCreateOptions”Options pour créer une alarme native via l'application d'horloge du système.
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;}NativeActionResult
Section intitulée “NativeActionResult”Résultat d'une action native.
export interface NativeActionResult { /** Whether the action was successful */ success: boolean; /** Optional message with additional information */ message?: string;}Informations retournées sur le système d'exploitation actuel et ses capacités.
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;}PermissionResult
Section intitulée “PermissionResult”Résultat d'une demande de permission.
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;}AlarmInfo
Section intitulée “AlarmInfo”Informations sur un alarme planifiée.
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;}Section intitulée “Source Of Truth”
Copier dans le presse-papierCette page est générée à partir du plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.