Getting Started
Copiez un prompt de configuration avec les étapes d'installation et le guide markdown complet 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 Aperçu
Section intitulée “API Aperçu”startMonitoringForRegion
Section intitulée “startMonitoringForRegion”Commencez à surveiller 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êtez de surveiller 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 à échantillonner des 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 balayer les balises 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 »Démarrez la publicité du dispositif en tant que balise iBeacon (iOS uniquement).
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 publier le dispositif en tant que balise iBeacon (iOS uniquement).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopAdvertising();requestWhenInUseAuthorization
Section intitulée « requestWhenInUseAuthorization »Demandez l'autorisation de localisation « En Utilisation » (obligatoire pour la balayage/monitorage).
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 » (nécessaire pour le suivi en arrière-plan).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
const { status } = await CapacitorIbeacon.requestAlwaysAuthorization();console.log('Authorization status:', status);getAuthorizationStatus
Section intitulée « getAuthorizationStatus »Obtenir le statut 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 le balayage 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 « enableARMAFilter »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 “enableBackgroundMode”Activer ou désactiver le mode de balayage de beacon en arrière-plan (seulement Android). Cela active un service de foreground pour une détection de beacon fiable en arrière-plan. Doit être appelé après avoir demandé l'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 “setBackgroundScanPeriod”Configurer les périodes de balayage en arrière-plan (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 typeSection intitulée “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
Section intitulée “Options d'annonces de phare”Options d'annonces de phare 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
Section intitulée “Options de période de scan de fond”Options de configuration de la période de scan de fond (Android uniquement).
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
Section intitulée “Données d’événement de balayage”Données d’événement lors de la détection de phares.
export interface RangingEventData { /** * Region that was ranged. */ region: BeaconRegion;
/** * Array of detected beacons. */ beacons: Beacon[];}MonitoringEventData
Section intitulée “Données d’événement de suivi”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ées.
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 De Vérité »Cette page est générée à partir du plugin’s src/definitions.tsRe-run la synchronisation lorsque les public API changent en amont.
Continuez de Getting Started
Section intitulée « Continuez de Getting Started »Si vous utilisez Getting Started planer le tableau de bord et les opérations API, connectez-le avec En utilisant @capgo/capacitor-ibeacon pour la capacité native dans En utilisant @capgo/capacitor-ibeacon, API Vue d'ensemble pour le détail d'implémentation dans API Vue d'ensemble, Introduction pour le détail d'implémentation dans Introduction, API Clés pour le détail d'implémentation dans API Clés, et Appareils pour le détail d'implémentation dans Appareils.