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.
インストール
「インストール」のセクション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」__CAPGO_KEEP_0__を範囲内に停止します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopRangingBeaconsInRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});startAdvertising
__CAPGO_KEEP_2____CAPGO_KEEP_0__デバイスをiBeaconとしてアドバタイズする (iOSのみ)。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startAdvertising({ uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D', major: 1, minor: 2, identifier: 'MyBeacon'});stopAdvertising
__CAPGO_KEEP_3____CAPGO_KEEP_0__デバイスをiBeaconとしてアドバタイズを停止する (iOSのみ)。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopAdvertising();requestWhenInUseAuthorization
__CAPGO_KEEP_4____CAPGO_KEEP_1__をクリップボードにコピー
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestWhenInUseAuthorization();console.log('Authorization status:', status);requestAlwaysAuthorization
__CAPGO_KEEP_1__をクリップボードにコピーRequest “Always” location authorization (required for background monitoring).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestAlwaysAuthorization();console.log('Authorization status:', status);getAuthorizationStatus
getAuthorizationStatus現在の位置の許可状態を取得します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.getAuthorizationStatus();console.log('Current status:', status);isBluetoothEnabled
isBluetoothEnabledデバイス上のBluetoothが有効かどうかを確認します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { enabled } = await CapacitorIbeacon.isBluetoothEnabled();if (!enabled) { console.log('Please enable Bluetooth');}isRangingAvailable
isRangingAvailableデバイス上の範囲が利用可能かどうかを確認します。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { available } = await CapacitorIbeacon.isRangingAvailable();if (available) { console.log('Ranging is supported');}enableARMAFilter
enableARMAFilter距離計算 (Android 限定) に対して ARMA フィルタを有効にする。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.enableARMAFilter({ enabled: true});enableBackgroundMode
「enableBackgroundMode」を含むセクションバックグラウンドビーコン スキャン モードを有効または無効にする (Android 限定)。 この機能は、信頼できるバックグラウンド ビーコン 検出のために、 foreground サービスを有効にする。 「常に」位置認可を要求した後、必ず呼び出してください。
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
// Enable background mode for beacon scanningawait CapacitorIbeacon.enableBackgroundMode({ enabled: true });
// Disable background modeawait CapacitorIbeacon.enableBackgroundMode({ enabled: false });setBackgroundScanPeriod
「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
「BeaconRegion」を含むセクションモニタリングと範囲指定のためにビーコン リージョンを定義します。
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
「ビーコン広告オプション」セクションiBeacon (iOSのみ)として送信するビーコン広告オプション。
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.tsAPI のパブリックがアップストリームで変更されたら、再度 Sync を実行してください。
Getting Started から続けて
「Getting Started から続けて」のセクションあなたが「Capgo」を使用している場合 Getting Started ダッシュボードとAPIの運用計画を立てるには、 Using @capgo/capacitor-ibeacon Using @capgo/capacitor-ibeaconのネイティブ機能 APIの概要 APIの概要の実装詳細 導入 導入の実装詳細 APIのキー APIのキーに関する実装詳細 デバイス デバイスに関する実装詳細