Zum Inhalt springen

Einstieg

GitHub

Sie können unsere AI-gestützte Einrichtung verwenden, um den Plugin zu installieren. Fügen Sie den Capgo-Fähigkeiten Ihre AI-Tool mithilfe der folgenden Befehl hinzu:

Terminal-Fenster
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Verwenden Sie dann die folgende Anfrage:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-ibeacon` plugin in my project.

Wenn Sie die manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und folgen Sie den unten angegebenen Plattform-spezifischen Anweisungen:

Terminal-Fenster
bun add @capgo/capacitor-ibeacon
bunx cap sync
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';

Starten Sie die Überwachung für eine Beacon-Region. Auslöst Ereignisse bei Eintritt/Austritt der Region.

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

Beenden Sie die Überwachung für eine Beacon-Region.

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

Starten Sie die Rangierung von Beacons in einer Region. Bietet ständige Entfernungsaktualisierungen.

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

Beacon-Überwachung in einer Region einstellen.

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

Das Gerät als iBeacon (nur iOS) als verfügbar ausgeben.

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

Das Gerät als iBeacon (nur iOS) als nicht verfügbar ausgeben.

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

Berechtigung für die Standortverwendung “Wenn in Gebrauch” anfordern (erforderlich für Ranging/Überwachung).

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

Anfrage “Always” Standortberechtigung (erforderlich für Hintergrundüberwachung).

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

Aktuelle Standortberechtigungsstatus abrufen.

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

Überprüfen, ob Bluetooth auf dem Gerät aktiviert ist.

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

Überprüfen, ob Ranging auf dem Gerät verfügbar ist.

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

Entsperren Sie die ARMA-Filterung für Entfernungsberechnungen (nur Android).

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

Aktivieren oder deaktivieren Sie den Hintergrund-Beacon-Scanningsmodus (nur Android). Dies aktiviert einen Vordergrunddienst für zuverlässige Hintergrundbeacon-Detektion. Muss nach der Anforderung der „Immer“-Standortberechtigung aufgerufen werden.

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

Konfigurieren Sie die Hintergrund-Scanaufenthalte (nur Android). Regelt, wie oft und wie lange das Gerät nach Beacons sucht, wenn es im Hintergrund ist.

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

Beacon-Regionen-Definition für das Monitoring und Rangieren.

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

Beacon-Werbeoptionen für die Übertragung als iBeacon (nur 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;
}

Konfigurationsoptionen für den Hintergrundscanauftritt (nur 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;
}

Daten zum Ereignis, wenn Beacon detektiert werden.

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

Daten zum Ereignis, wenn ein Bereich betreten oder verlassen wird.

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

Beacon-Informationen wurden erkannt.

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

Diese Seite wurde aus dem Plugin generiert. src/definitions.tsRe-run the sync, wenn die öffentliche API upstream geändert wird.

Wenn Sie Getting Started Um das Dashboard und die API-Operationen zu planen, verbinden Sie es mit Mit @capgo/capacitor-ibeacon Für die native Fähigkeit in Mit @capgo/capacitor-ibeacon API-Übersicht Für die Implementierungsdetails in API-Übersicht Einführung Für die Implementierungsdetails in Einführung API-Schlüssel Für die Implementierungsdetails in API-Schlüssel und Geräte Für die Implementierungsdetails in Geräte.