ガイド
How to use Alarm in Capacitor
Using @capgo/capacitor-alarm
Capacitor Alarm Pluginのインターフェイス
Install
bun add @capgo/capacitor-alarm
bunx cap sync
bunx cap sync プラグインのネイティブ code をあなたのネイティブ プロジェクトにコピーします。プラグインのアップグレード後は再度実行してください。
Import
import { CapgoAlarm } from '@capgo/capacitor-alarm';
APIの概要
| Method | 説明 |
|---|---|
createAlarm |
プラットフォームの時計アプリを使用してネイティブOSのアラームを作成します。Androidではアラームクロックのインテントを使用し、iOSではAlarmKitを使用します (iOS 16以上)。 |
openAlarms |
プラットフォームのネイティブアラームリストUIを開きます (利用可能な場合)。 |
getOSInfo |
OSの情報と機能を取得します。 |
requestPermissions |
プラットフォーム上のアラームの使用に必要な権限を要求します。Androidの場合、正確なアラームの設定にルーティングする場合があります。 |
checkPermissions |
nativeアラームへのアクセス権の現在の状態を確認します。iOSではAlarmKitの準備状況を、Androidでは機能詳細を報告します。 |
getAlarms |
このアプリによって設定されたスケジュールされたアラームの一覧を取得します。iOS 26+では、AlarmKitからアラームを取得します。Androidでは、システムがアラームを検索するためのAPIを提供していないため、サポートされていません。 |
cancelAlarm |
指定されたIDのスケジュールされたアラームをキャンセルします。iOS 26+では、AlarmKitからアラームを削除します。Android/Webでは、サポートされていません。 |
例
createAlarm()
コンテキスト: バグバウティープログラムページ。役割: セクションまたはページヘッダー。見られる場所: bug-bounty.astroページ。メッセージキー `bug_bounty_supabase_examples_title` (Bug Bounty Supabase Examples Title)。
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()
プラットフォームのネイティブなアラームリストUIを開きます。
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const result = await CapgoAlarm.openAlarms();
if (result.success) {
console.log('Alarms UI opened');
}
getOSInfo()
プラットフォームのネイティブアラームリストUIを開きます (利用可能な場合)。
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()
nativeアラームへのアクセス権の現在の状態を確認します。iOSではAlarmKitの準備状況を、Androidでは機能詳細を報告します。
import { CapgoAlarm } from '@capgo/capacitor-alarm';
const status = await CapgoAlarm.checkPermissions();
console.log('AlarmKit allowed?', status.details?.alarmKit);
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}`);
});
OSと機能に関する情報を取得します。 GitHub リポジトリ.
フルリファレンス
capgo/capacitor-alarmを使用している場合
__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-alarmを使用しています capgo/capacitor-alarmと接続して __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-alarmの実装詳細を参照してください @capgo/capacitor-alarm @capgo/capacitor-alarmの実装詳細のために 続けてください Capacitor-アラーム用プラグインのインストールと設定 Capgo プラグインディレクトリ Capacitor Alarmの製品ワークフローに於けるCapgo プラグインディレクトリです。 Capacitor Capgo プラグイン for Capacitor の実装詳細については、Capgo によって提供されるプラグインを参照してください。 プラグインの追加または更新 Capacitor-アラーム用プラグインの詳細