はじめに
インストールステップとこのプラグインの全マークダウンガイドを含む設定用の質問をコピーする
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.
インストール
「インストール」というセクションbun add @capgo/capacitor-alarmbunx cap syncインポート
「インポート」というセクションimport { CapgoAlarm } from '@capgo/capacitor-alarm';API の概要
API の概要というセクションcreateAlarm
createAlarm というセクションプラットフォームの時計アプリを使用して、ネイティブのOSアラームを作成します。 Androidでは、Alarm Clock インテントを使用します。iOSでは、AlarmKitが利用可能な場合 (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
__CAPGO_KEEP_0__ の概要というセクション__CAPGO_KEEP_0__ の概要というセクション
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();if (result.success) { console.log('Alarms UI opened');}コピー
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
許可を要求するアラームの使用に必要な許可を、プラットフォームで取得します。 Androidの場合、正確なアラームの設定にルーティングする場合があります。
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
許可の状態を確認するこのアプリが使用するネイティブアラームへのアクセスをトリガーせずに、現在の許可状態を確認します。 iOSの場合、AlarmKitの準備状況を報告します。Androidの場合、機能詳細を報告します。
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();console.log('AlarmKit allowed?', status.details?.alarmKit);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}`);});型の参照
型の参照NativeAlarmCreateOptions
ネイティブアラームの作成オプションプラットフォーム時計アプリを使用したネイティブOSアラームの作成オプション。
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
「NativeActionResult」セクションネイティブアクションの結果
export interface NativeActionResult { /** Whether the action was successful */ success: boolean; /** Optional message with additional information */ message?: string;}OSInfo
「OSInfo」セクション現在のOSと機能に関する情報
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
「PermissionResult」セクションパーミッションの要求結果
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
「AlarmInfo」セクション予定されたアラームに関する情報。
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;}真実の源
「真実の源」というセクションプラグインの情報から生成されたこのページは、 src/definitions.tsAPIがアップストリームで変更された場合に再度同期を実行してください。