Einstieg
Eine Einrichtungsvorlage mit den Installationsanweisungen und der vollständigen Markdown-Guideline für diesen Plugin kopieren.
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.
Installieren
Abschnitt mit dem Titel „Installieren“bun add @capgo/capacitor-alarmbunx cap syncImportieren
Abschnitt mit dem Titel „Importieren“import { CapgoAlarm } from '@capgo/capacitor-alarm';API Übersicht
Abschnitt mit dem Titel „API Übersicht“createAlarm
Abschnitt mit dem Titel „createAlarm“Erstellen Sie einen nativen Betriebssystem-Alarm mithilfe der Uhr des Betriebssystems. Bei Android wird der Alarm Clock-Intent verwendet; bei iOS wird AlarmKit verwendet, wenn verfügbar (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
Abschnitt mit dem Titel “openAlarms”Öffnen Sie die nativen Alarmliste des Betriebssystems, wenn verfügbar.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();if (result.success) { console.log('Alarms UI opened');}getOSInfo
Abschnitt mit dem Titel “getOSInfo”Ermitteln Sie Informationen über das Betriebssystem und die verfügbaren Funktionen.
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
Abschnitt mit dem Titel “requestPermissions”Bitten Sie um die relevanten Berechtigungen für den Alarm-Verwendung auf dem Betriebssystem an. Bei Android kann dies zu den Einstellungen für genaue Alarms führen.
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
Abschnitt mit dem Titel “checkPermissions”Überprüfen Sie den aktuellen Berechtigungsstatus für Zugriff auf native Alarme ohne Auslösen der Benutzeroberfläche.
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();console.log('AlarmKit allowed?', status.details?.alarmKit);getAlarms
Abschnitt mit dem Titel „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}`);});Typenreferenz
Abschnitt mit dem Titel „Typenreferenz“NativeAlarmCreateOptions
Abschnitt mit dem Titel „NativeAlarmCreateOptions“Optionen für die Erstellung eines nativen Betriebssystemalarms über die Plattform-Uhr-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;}NativeActionResult
Abschnitt mit dem Titel „NativeActionResult“Ergbnis einer nativen Aktion.
export interface NativeActionResult { /** Whether the action was successful */ success: boolean; /** Optional message with additional information */ message?: string;}Gibt Informationen über den aktuellen Betriebssystem und seine Fähigkeiten zurück.
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
Abschnitt mit dem Titel “PermissionResult”Ergibt sich aus einer Anfrage zur Berechtigung.
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
Abschnitt mit dem Titel “AlarmInfo”Bietet Informationen über einen geplanten 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;}Abschnitt mit dem Titel “Source Of Truth”
Copy to clipboardDiese Seite wurde aus dem Plugin generiert. src/definitions.tsRe-run die Synchronisation, wenn die öffentliche API sich upstream ändert.