Socket
Book a DemoInstallSign in
Socket

@wisdomgarden/capacitor-plugin-beacon

Package Overview
Dependencies
Maintainers
7
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wisdomgarden/capacitor-plugin-beacon

Capacitor plugin for Bluetooth beacon broadcasting and monitoring

latest
npmnpm
Version
0.0.1
Version published
Maintainers
7
Created
Source

Capacitor Beacon Plugin

A Capacitor plugin for Bluetooth beacon functionality.

Installation

npm install @wisdomgarden/capacitor-plugin-beacon
npx cap sync

API

initialize

Initialize the beacon plugin.

await Beacon.initialize({ allowDuplicatesKey: true });

startBroadcasting

Start broadcasting as a beacon. You can either provide a complete message or individual components.

await Beacon.startBroadcasting({
  rollcallId: 123,
  nonce: "ZABC"
});

stopBroadcasting

Stop broadcasting as a beacon.

await Beacon.stopBroadcasting();

startMonitoring

Start monitoring for nearby beacons.

await Beacon.startMonitoring();

stopMonitoring

Stop monitoring for nearby beacons.

await Beacon.stopMonitoring();

cleanup

Clean up all beacon-related resources.

await Beacon.cleanup();

parseMessage

Parse a beacon message into its components.

const result = await Beacon.parseMessage({ message: "xxxxxx" });
// Returns: { rollcallId: number, nonce: string }

Events

beaconReceived

Emitted when a beacon is discovered.

Beacon.addListener('beaconReceived', (data) => {
  console.log('Received beacon:', data);
  // data: { message: string, rssi: number, peripheralId: string, timestamp: number }
});

stateUpdated

Emitted when the peripheral state changes.

Beacon.addListener('stateUpdated', (data) => {
  console.log('State updated:', data);
  // data: { type: 'peripheral', state: 'poweredOn' | 'poweredOff' | 'unauthorized' | 'unsupported' | number }
});

stateError

Emitted when there's an error with the beacon state.

Beacon.addListener('stateError', (data) => {
  console.log('State error:', data);
  // data: { type: 'peripheral' | 'central', state: string }
});

bluetoothStateChanged

Emitted when the Bluetooth state changes.

Beacon.addListener('bluetoothStateChanged', (data) => {
  console.log('Bluetooth state changed:', data);
  // data: { enabled: boolean, error?: string }
});

Platform Support

  • iOS ✅
  • Android ✅
  • Web ❌ (Not supported)

Platform Specific Notes

iOS

  • Requires NSBluetoothAlwaysUsageDescription and NSBluetoothPeripheralUsageDescription in Info.plist
  • Minimum iOS version: 11.0

Android

  • Requires BLUETOOTH, BLUETOOTH_ADMIN, BLUETOOTH_SCAN, BLUETOOTH_CONNECT, and BLUETOOTH_ADVERTISE permissions
  • Minimum Android version: API level 21 (Android 5.0)
  • Requires location services to be enabled for scanning beacons

License

Apache-2.0

Keywords

capacitor

FAQs

Package last updated on 27 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts