Démarrage
Copier un prompt de configuration avec les étapes d'installation et la guide markdown complète pour ce plugin.
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.
Installer
Section intitulée « Installer »bun add @capgo/capacitor-ibeaconbunx cap syncImporter
Section intitulée “Importer”import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';API Vue d'ensemble
Section intitulée “API Vue d'ensemble”startMonitoringForRegion
Section intitulée “startMonitoringForRegion”Démarrer la surveillance d'une région de beacon. Déclenche des événements lors de l'entrée/sortie de la région.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startMonitoringForRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});stopMonitoringForRegion
Section intitulée “stopMonitoringForRegion”Arrêter la surveillance d'une région de beacon.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopMonitoringForRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});startRangingBeaconsInRegion
Section intitulée “startRangingBeaconsInRegion”Commencez à détecter les beacons dans une région. fournit des mises à jour continues de distance.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startRangingBeaconsInRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});stopRangingBeaconsInRegion
Section intitulée “stopRangingBeaconsInRegion”Arrêtez de détecter les beacons dans une région.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopRangingBeaconsInRegion({ identifier: 'MyBeaconRegion', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'});startAdvertising
Section intitulée “startAdvertising”Commencez à faire de l'appareil un iBeacon (seulement iOS).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.startAdvertising({ uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D', major: 1, minor: 2, identifier: 'MyBeacon'});stopAdvertising
Section intitulée “stopAdvertising”Arrêtez de faire de l'appareil un iBeacon (seulement iOS).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopAdvertising();requestWhenInUseAuthorization
Section intitulée “requestWhenInUseAuthorization”Demandez l'autorisation de localisation « Lors de l'utilisation » (obligatoire pour la localisation/répartition).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestWhenInUseAuthorization();console.log('Authorization status:', status);requestAlwaysAuthorization
Section intitulée « requestAlwaysAuthorization »Demandez l'autorisation de localisation « Toujours » (obligatoire pour la surveillance de fond).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestAlwaysAuthorization();console.log('Authorization status:', status);getAuthorizationStatus
Section intitulée « getAuthorizationStatus »Obtenez l'état actuel de l'autorisation de localisation.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.getAuthorizationStatus();console.log('Current status:', status);isBluetoothEnabled
Section intitulée « isBluetoothEnabled »Vérifiez si le Bluetooth est activé sur le dispositif.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { enabled } = await CapacitorIbeacon.isBluetoothEnabled();if (!enabled) { console.log('Please enable Bluetooth');}isRangingAvailable
Section intitulée « isRangingAvailable »Vérifiez si la plage est disponible sur le dispositif.
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { available } = await CapacitorIbeacon.isRangingAvailable();if (available) { console.log('Ranging is supported');}enableARMAFilter
Section intitulée « activer le filtre ARMA »Activer le filtrage ARMA pour les calculs de distance (seulement Android).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.enableARMAFilter({ enabled: true});enableBackgroundMode
Section intitulée « activer le mode de fond »Activer ou désactiver le mode de balayage de fond de beacon (seulement Android). Cela active un service de fond pour une détection de beacon fiable en arrière-plan. Doit être appelé après avoir demandé une autorisation de localisation « Toujours ».
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
// Enable background mode for beacon scanningawait CapacitorIbeacon.enableBackgroundMode({ enabled: true });
// Disable background modeawait CapacitorIbeacon.enableBackgroundMode({ enabled: false });setBackgroundScanPeriod
Section intitulée « configurer la période de balayage de fond »Configurer les périodes de balayage de fond (seulement Android). Contrôle combien souvent et pendant combien de temps le dispositif scanne les beacons en arrière-plan.
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});Référence de type
Référence de typeBeaconRegion
Référence de région de BeaconDéfinition de la région de Beacon pour le suivi et la recherche.
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
Options d'annonce de BeaconOptions d'annonce de Beacon pour la transmission sous forme d'iBeacon (iOS uniquement).
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
Options de période de scan de fond (Android uniquement).Copier dans le presse-papier
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
Copier dans le presse-papierCopier dans le presse-papier
export interface RangingEventData { /** * Region that was ranged. */ region: BeaconRegion;
/** * Array of detected beacons. */ beacons: Beacon[];}MonitoringEventData
Section intitulée “MonitoringEventData”Données d'événement lors de l'entrée ou de la sortie d'une région.
export interface MonitoringEventData { /** * Region that triggered the event. */ region: BeaconRegion;
/** * Event state: 'enter' or 'exit'. */ state: 'enter' | 'exit';}Informations sur le beacon détecté.
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;}Source De Vérité
Section intitulée “Source Of Truth”Cette page est générée à partir du plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.