メインコンテンツにジャンプ

Getting Started

GitHub

Capgoの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-ibeacon` plugin in my project.

Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

ターミナル画面
bun add @capgo/capacitor-ibeacon
bunx cap sync

インポート

インポート
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';

API オーバービュー

API オーバービュー

startMonitoringForRegion

__CAPGO_KEEP_0__

地域のビーコンを監視して開始します。エントリ/エクィティ地域のイベントをトリガーします。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startMonitoringForRegion({
identifier: 'MyBeaconRegion',
uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
});

stopMonitoringForRegion

__CAPGO_KEEP_0__

地域のビーコンを監視して停止します。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopMonitoringForRegion({
identifier: 'MyBeaconRegion',
uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
});

startRangingBeaconsInRegion

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startRangingBeaconsInRegion({
identifier: 'MyBeaconRegion',
uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
});

__CAPGO_KEEP_1__

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopRangingBeaconsInRegion({
identifier: 'MyBeaconRegion',
uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
});

__CAPGO_KEEP_2__

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startAdvertising({
uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D',
major: 1,
minor: 2,
identifier: 'MyBeacon'
});

__CAPGO_KEEP_0__

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopAdvertising();

requestWhenInUseAuthorization

__CAPGO_KEEP_0__

Request “When In Use” location authorization (required for ranging/monitoring).

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestWhenInUseAuthorization();
console.log('Authorization status:', status);

Request “Always” location authorization (required for background monitoring).

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestAlwaysAuthorization();
console.log('Authorization status:', status);

Get current location authorization status.

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.getAuthorizationStatus();
console.log('Current status:', status);

Bluetooth が有効かどうかを確認します。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { enabled } = await CapacitorIbeacon.isBluetoothEnabled();
if (!enabled) {
console.log('Please enable Bluetooth');
}

デバイスで範囲が利用可能かどうかを確認します。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { available } = await CapacitorIbeacon.isRangingAvailable();
if (available) {
console.log('Ranging is supported');
}

距離計算用にARMフィルタを有効にします (Android 限定)。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.enableARMAFilter({
enabled: true
});

バックグラウンドビーコン スキャニング モードを有効または無効にします (Android 限定)。 この機能は、信頼性の高いバックグラウンド ビーコン 検出のために、前景サービスを有効にします。 「常に」位置認可を要求した後、呼び出す必要があります。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
// Enable background mode for beacon scanning
await CapacitorIbeacon.enableBackgroundMode({ enabled: true });
// Disable background mode
await CapacitorIbeacon.enableBackgroundMode({ enabled: false });

バックグラウンド スキャン ペリオドを設定します (Android 限定)。 バックグラウンドでビーコンを検索する頻度と期間を制御します。

import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
// Set background scan to 10 seconds every 30 seconds
await CapacitorIbeacon.setBackgroundScanPeriod({
scanPeriod: 10000, // 10 seconds of scanning
betweenScanPeriod: 30000 // 30 seconds between scans
});

型参照

種類参照

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

ビーコン広告オプション

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;
}

クリップボードにコピー

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;
}

クリップボードにコピー

export interface RangingEventData {
/**
* Region that was ranged.
*/
region: BeaconRegion;
/**
* Array of detected beacons.
*/
beacons: Beacon[];
}

地域に入ったり出たりするときのイベントデータ.

export interface MonitoringEventData {
/**
* Region that triggered the event.
*/
region: BeaconRegion;
/**
* Event state: 'enter' or 'exit'.
*/
state: 'enter' | 'exit';
}

ビーコン情報の検出.

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. upstreamの公開 API が変更されたら、再度同期を実行してください。

Getting Startedから続けてください

「Getting Started」から続けてください

__CAPGO_KEEP_0__を使用している場合 Getting Started APIを使用してダッシュボードとAPIの操作を計画する場合、APIを接続してください capgo/capacitor-ibeaconを使用する Using @capgo/capacitor-ibeaconのネイティブ機能 APIの概要 APIの実装詳細 Introduction Introductionの実装詳細 API Keys API Keysの実装詳細 デバイス デバイスの実装詳細について