スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
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.
インストール
「インストール」セクションAIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用します:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-alarm` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-alarmnpx cap syncインポート
「インポート」セクションimport { CapgoAlarm } from '@capgo/capacitor-alarm';クイックスタート
「クイックスタート」セクション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
「例: openAlarms」というタイトルのセクションimport { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();if (result.success) { console.log('Alarms UI opened');}例: getOSInfo
「例: getOSInfo」というタイトルのセクション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);}よくある落とし穴
「よくある落とし穴」セクション- 権限: 呼び出し
checkPermissions()その後requestPermissions()必要に応じて。 - ネイティブ同期: 実行
npx cap syncプラグインのアップグレード後。 - 信頼できる情報源: 信頼
src/definitions.tsGitHub リポジトリ内。
API の概要
「API 概要」セクションcreateAlarm
「createAlarm」セクションプラットフォームの時計アプリを使用して、ネイティブOSのアラームを作成します。 AndroidではAlarm Clock intentを使用し、iOSでは利用可能な場合(iOS 16以降)AlarmKitを使用します。
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
「openAlarms」セクション利用可能な場合、プラットフォーム標準のアラーム一覧UIを開きます。
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();if (result.success) { console.log('Alarms UI opened');}getOSInfo
「getOSInfo」セクションOSの情報と利用可能な機能を取得します。
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
「requestPermissions」セクションプラットフォーム上でアラームを使用するために、必要な権限をリクエストします。 Androidでは、正確なアラーム(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');}checkPermissions
「checkPermissions」セクションUIを表示せずに、ネイティブのアラームアクセスに関する現在の権限状態を確認します。 iOSではAlarmKitの準備状況を、Androidでは機能の詳細を返します。
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();console.log('AlarmKit allowed?', status.details?.alarmKit);getAlarms
「getAlarms」セクションこのアプリによってスケジュールされたアラームの一覧を取得します。 iOS 26以降ではAlarmKitからアラームを返します。Androidでは、システムがアラームを照会するための API を提供していないため、この機能はサポートされていません。
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}`);});型リファレンス
「Type Reference」セクションNativeAlarmCreateOptions
「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;}Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-alarm の使用方法 @capgo/capacitor-alarm でネイティブ機能を使用する場合、 API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。