Accueil
Copiez un prompt de configuration avec les étapes d'installation et la guide Markdown complète 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 »Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA à l'aide de la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsUtilisez ensuite la prompt suivante :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-alarm` plugin in my project.Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :
bun add @capgo/capacitor-alarmbunx cap syncImporter
Section intitulée « Importer »import { CapgoAlarm } from '@capgo/capacitor-alarm';API : Présentation
Section intitulée « API : Présentation »createAlarm
Section intitulée « créerAlarm »Créez un alarme native du système d'exploitation en utilisant l'application d'horloge du système.
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 UI native des alarmes 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.
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
Copier dans le presse-papierVérifiez l'état actuel des autorisations pour l'accès à l'alarme native sans déclencher l'interface utilisateur. Sur iOS, cela signale la disponibilité d'AlarmKit ; sur Android, cela signale les détails de la capacité.
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 “Référence de type”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 renvoyé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;}Source De Vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin’s src/definitions.tsRe-run la synchronisation lorsque les informations publiques API changent en amont.
Continuez de la section « Continuez de la section «
Si vous utilisez « Continuez de la section «Pour planifier le tableau de bord et les opérations __CAPGO_KEEP_0__, connectez-l’à Utilisez @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-alarm pour la capacité native dans Utilisez @API/__CAPGO_KEEP_1__-alarm Using @capgo/capacitor-alarm for the native capability in Using @capgo/capacitor-alarm, API Overview for the implementation detail in API Overview, if you are using pour les détails d'implémentation dans Introduction API Clés pour les détails d'implémentation dans API Clés, et Appareils pour les détails d'implémentation dans Appareils.