Cordova Bluetooth status is a Cordova plugin allowing to check for Bluetooth adapter status. The plugin currently offers the following features:
- check for Bluetooth capability
- check for Bluetooth LE capability
- check if use of Bluetooth is authorized (iOS only)
- monitor/check Bluetooth enabled/disabled state
- force Bluetooth activation (Android only)
- prompt the user to enable the Bluetooth (Android only)
- Android
- iOS
cordova plugin add cordova-plugin-bluetooth-status
This plugin exports its methods and properties on cordova.plugins.BluetoothStatus
.
Variable storing the presence of a Bluetooth device
Variable storing the presence of a Bluetooth LE device
Variable storing the state of the Bluetooth adapter (enabled or not)
Variable storing the authorization to use the Bluetooth adapter on iOS
Initialize the plugin and populate the initial state of the Bluetooth adapter
cordova.plugins.BluetoothStatus.initPlugin();
Activate the Bluetooth without prompting the user:
cordova.plugins.BluetoothStatus.enableBT();
Prompt the user to activate the Bluetooth:
cordova.plugins.BluetoothStatus.promptForBT();
These events are fired on the window
object.
This event is triggered when the Bluetooth adapter gets enabled.
window.addEventListener('BluetoothStatus.enabled', function() {
console.log('Bluetooth has been enabled');
});
This event is triggered when the Bluetooth adapter gets disabled.
window.addEventListener('BluetoothStatus.disabled', function() {
console.log('Bluetooth has been disabled');
});
- correct some build errors for older Android versions