Getting Started
このプラグインのインストール手順と全体のマークダウンガイドを含むセットアップコマンドをコピーできます。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-ibeacon`
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/ibeacon/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.
インストール
「インストール」のセクションCapgoのAI-Assisted Setupを使用してプラグインをインストールできます。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-ibeacon` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行してください。プラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-ibeaconbunx cap syncインポート
「インポート」のセクションimport { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';APIの概要
「APIの概要」のセクションstartMonitoringForRegion
「startMonitoringForRegion」セクション地域のビーコンを監視して開始します。地域に入ったり出たりするときにイベントがトリガーされます。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startMonitoringForRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});stopMonitoringForRegion
「stopMonitoringForRegion」セクション地域のビーコンを監視して停止します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopMonitoringForRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});startRangingBeaconsInRegion
「startRangingBeaconsInRegion」セクション地域内のビーコンを検出して開始します。距離の連続的な更新が提供されます。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startRangingBeaconsInRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});stopRangingBeaconsInRegion
「stopRangingBeaconsInRegion」セクション地域内のビーコンを検出して停止します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopRangingBeaconsInRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});startAdvertising
startAdvertisingiOSのみで、iBeaconとしてデバイスを広告します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startAdvertising({ uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D', major: 1, minor: 2, identifier: 'MyBeacon'});stopAdvertising
アドバタイズメントを停止するiOSのみで、iBeaconとしてのデバイスの広告を停止します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopAdvertising();requestWhenInUseAuthorization
「requestWhenInUseAuthorization」位置情報の「使用中」認可の要求 (範囲検出/監視のために必要)。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestWhenInUseAuthorization();console.log('Authorization status:', status);requestAlwaysAuthorization
「常時許可要求」位置情報の「常に」認可の要求 (バックグラウンド監視のために必要)。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestAlwaysAuthorization();console.log('Authorization status:', status);getAuthorizationStatus
Section titled “位置情報の取得許可状況”現在の位置情報取得許可状況を取得します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.getAuthorizationStatus();console.log('Current status:', status);isBluetoothEnabled
Section titled “Bluetoothが有効かどうか”デバイス上のBluetoothが有効かどうかを確認します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { enabled } = await CapacitorIbeacon.isBluetoothEnabled();if (!enabled) { console.log('Please enable Bluetooth');}isRangingAvailable
Section titled “範囲検出が可能かどうか”デバイス上の範囲検出が可能かどうかを確認します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { available } = await CapacitorIbeacon.isRangingAvailable();if (available) { console.log('Ranging is supported');}enableARMAFilter
Section titled “ARMAフィルタを有効にする”距離計算用のARMAフィルタを有効にします (Android専用)
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.enableARMAFilter({ enabled: true});enableBackgroundMode
Section titled “バックグラウンドモードを有効にする”バックグラウンドビーコン検出モードを有効または無効します (Android 限定)。 この機能は、信頼性の高いバックグラウンドビーコン検出のために、前景サービスを有効にします。 「常に」位置認可を要求した後、必ず呼び出してください。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
// Enable background mode for beacon scanningawait CapacitorIbeacon.enableBackgroundMode({ enabled: true });
// Disable background modeawait CapacitorIbeacon.enableBackgroundMode({ enabled: false });setBackgroundScanPeriod
背景スキャン周期を設定バックグラウンドスキャン期間を設定します (Android 限定)。 バックグラウンドでデバイスがビーコンを検索する頻度と期間を制御します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
// Set background scan to 10 seconds every 30 secondsawait CapacitorIbeacon.setBackgroundScanPeriod({ scanPeriod: 10000, // 10 seconds of scanning betweenScanPeriod: 30000 // 30 seconds between scans});リファレンス
「型参照」BeaconRegion
Section titled “ビーコン地域”ビーコン地域の定義 (モニタリングと範囲指定用)。
export interface BeaconRegion { /** * Unique identifier for this region. */ identifier: string;
/** * UUID of the beacon(s) to detect. */ uuid: string;
/** * Major value for filtering (optional). */ major?: number;
/** * Minor value for filtering (optional). */ minor?: number;
/** * Notify when device enters region (iOS only). */ notifyEntryStateOnDisplay?: boolean;
/** * Enable Android background mode for this monitoring/ranging call. * When true, the plugin will keep scanning in background using a foreground service. */ enableBackgroundMode?: boolean;}BeaconAdvertisingOptions
Section titled “ビーコン広告オプション”iOSのみでiBeaconとして送信するためのビーコン広告オプション。
export interface BeaconAdvertisingOptions { /** * UUID to advertise. */ uuid: string;
/** * Major value (0-65535). */ major: number;
/** * Minor value (0-65535). */ minor: number;
/** * Identifier for the advertising beacon. */ identifier: string;
/** * Measured power (RSSI at 1 meter). Optional, defaults to -59. */ measuredPower?: number;}BackgroundScanPeriodOptions
背景スキャン期間オプションAndroidのみの背景スキャン期間の設定オプション。
export interface BackgroundScanPeriodOptions { /** * Duration of each scan period in milliseconds. * Default: 10000 (10 seconds) */ scanPeriod?: number;
/** * Duration between scan periods in milliseconds. * Default: 15000 (15 seconds) */ betweenScanPeriod?: number;}RangingEventData
ビーコン範囲データビーコンが範囲内に入ったときのイベントデータ。
export interface RangingEventData { /** * Region that was ranged. */ region: BeaconRegion;
/** * Array of detected beacons. */ beacons: Beacon[];}MonitoringEventData
ビーコン範囲データビーコンが範囲内に入ったり出たときのイベントデータ。
export interface MonitoringEventData { /** * Region that triggered the event. */ region: BeaconRegion;
/** * Event state: 'enter' or 'exit'. */ state: 'enter' | 'exit';}Beacon
ビーコン検出されたビーコン情報。
export interface Beacon { /** * Beacon UUID. */ uuid: string;
/** * Major value. */ major: number;
/** * Minor value. */ minor: number;
/** * RSSI (Received Signal Strength Indicator). */ rssi: number;
/** * Proximity: 'immediate', 'near', 'far', or 'unknown'. */ proximity: 'immediate' | 'near' | 'far' | 'unknown';
/** * Estimated distance in meters. */ accuracy: number;}真実の源
「真実の源」このページはプラグインの src/definitions.ts再同期するには、公開されたAPIがアップストリームで変更されたときに実行してください。
「始めてみよう」
「始めてみよう」Capacitorを使用している場合 「始めてみよう」 Capacitorを使用してダッシュボードとAPIの作業を計画する場合、@API/__CAPGO_KEEP_1__-ibeaconと接続してください。 @capgo/capacitor-iBeacon capgoのネイティブ機能を使用するために@capacitor/capgo-ibeacon APIの概要 APIの実装詳細 Introduction __CAPGO_KEEP_0__の概要 APIのキーの実装詳細 API Devices __CAPGO_KEEP_0__