Débuter
Copiez 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
Sous-section intitulée « Installer »Vous pouvez utiliser notre Setup assisté par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA en utilisant la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsEnsuite, utilisez la prompt suivante :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-ibeacon` plugin in my project.Si vous préférez le Setup manuel, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :
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 »Commencer à 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ê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 beacon iBeacon (disponible uniquement sur 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 beacon iBeacon (disponible uniquement sur iOS).
import { CapacitorIbeacon } from '@capgo/capacitor-ibeacon';
await CapacitorIbeacon.stopAdvertising();requestWhenInUseAuthorization
Section intitulée « requestWhenInUseAuthorization »Demandez l'autorisation de localisation « Lors de l'utilisation » (nécessaire pour la recherche/réception).
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 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 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
Sous-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
Sous-section intitulée « activer le mode de balayage de fond »Activer ou désactiver le mode de balayage de fond de beacon (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é 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
Sous-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 combien longtemps le dispositif balaye 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
Titre de la section « Référence de type »BeaconRegion
Titre de la section « BeaconRegion »Définition de la région beacon pour la surveillance 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
Titre de la section « Options d'annonce de beacon »Options d'annonce de beacon pour la transmission sous forme d'iBeacon (disponible uniquement sur 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;}BackgroundScanPeriodOptions
Titre de la section « Options de période de balayage en arrière-plan »Options de configuration de la période de balayage en arrière-plan (disponible uniquement sur 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;}Données d'événement lors de la recherche de beacons.
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 De Vérité »Cette page est générée à partir du plugin's src/definitions.tsRe-faire la synchronisation lorsque les données publiques API changent en amont.
Continuez de la section « Getting Started »
Section intitulée « Continuez de l'Accueil »Si vous utilisez Accueil pour planifier votre tableau de bord et les opérations API Using @capgo/capacitor-ibeacon Utilisation de @capgo/capacitor-ibeacon pour la capacité native dans Utilisation de @API/__CAPGO_KEEP_1__-ibeacon API Vue d'ensemble pour les détails d'implémentation dans __CAPGO_KEEP_0__ Vue d'ensemble Introduction API Keys API Clés Appareils pour le détail d'implémentation dans Appareils.