コンテンツにジャンプ

Getting Started

GitHub

AI-Assisted セットアップを使用してプラグインをインストールできます。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.

あなたがマニュアルセットアップを好む場合は、プラグインをインストールするには、以下のコマンドを実行し、以下のプラットフォーム固有の説明を参照してください:

ターミナルウィンドウ
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'
});

stopMonitoringForRegion

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

startRangingBeaconsInRegion

__CAPGO_KEEP_3__

__CAPGO_KEEP_4__

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

stopRangingBeaconsInRegion

__CAPGO_KEEP_5__

__CAPGO_KEEP_0__

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

startAdvertising

__CAPGO_KEEP_0__

__CAPGO_KEEP_7__

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

範囲/監視のために必要な「使用中」位置の許可を求めます。

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

背景監視のために必要な「常に」位置の許可を求めます。

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

クリップボードにコピー

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

クリップボードにコピー

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

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_3__

__CAPGO_KEEP_1__

BeaconRegion

__CAPGO_KEEP_4__

__CAPGO_KEEP_5__

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

__CAPGO_KEEP_6__

__CAPGO_KEEP_7__

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

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

RangingEventData

ビーコンが範囲内に検出されたときのイベントデータ。

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

MonitoringEventData

MonitoringEventData

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

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

Beacon

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 がアップストリームで変更された場合に、再度 Sync を実行してください。

Getting Started から続けてください

Getting Started から続けてくださいのセクション

あなたが Getting Started ダッシュボードと API の作業を計画する場合、 Using @capgo/capacitor-ibeacon Using @capgo/capacitor-ibeacon のnative capability API オーバービュー 実装詳細については API の概要を参照してください。 概要 実装詳細については概要を参照してください。 API のキー 実装詳細については API のキー、 デバイス 実装詳細についてはデバイスを参照してください。