__CAPGO_KEEP_1__

Getting Started

GitHub

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-ibeacon
bunx cap sync
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';

地域のビーコンを監視して開始します。地域に入ったり出たりするときにイベントがトリガーされます。

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

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

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

地域内のビーコンを検出して開始します。距離の連続的な更新が提供されます。

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

地域内のビーコンを検出して停止します。

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

startAdvertising

startAdvertising

iOSのみで、iBeaconとしてデバイスを広告します。

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

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

現在の位置情報取得許可状況を取得します。

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

距離計算用のARMAフィルタを有効にします (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 });

setBackgroundScanPeriod

背景スキャン周期を設定

バックグラウンドスキャン期間を設定します (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
});

リファレンス

「型参照」

ビーコン地域の定義 (モニタリングと範囲指定用)。

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

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

ビーコンが範囲内に入ったときのイベントデータ。

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

検出されたビーコン情報。

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__