Reputation: 67
The following code, executing on a chromebook with Chrome version 59.0.3071.134 (Official Build) (64-bit) is generating "Uncaught TypeError: navigator.bluetooth.getAvailability is not a function". Any idea why?
bluetoothle.checkBluetoothAvailable = function() {
console.log("checkBluetoothAvailable");
navigator.bluetooth.getAvailability().then(isAvailable => {
document.getElementById('btn_discover').hidden = !isAvailable;
if (!isAvailable) {
document.getElementById('message').innerHTML = 'Bluetooth is not available';
}
});
navigator.bluetooth.addEventListener('availabilitychanged', e => {
document.getElementById('btn_discover').hidden = !e.value;
if (!e.value) {
document.getElementById('message').innerHTML = 'Bluetooth is not available';
} else {
document.getElementById('message').innerHTML = 'Bluetooth is available';
}
});
}
Upvotes: 1
Views: 1713
Reputation: 18600
getAvailability is not implemented. It is specified, so it makes sense to try it and expect it to work.
https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md lists what has been implemented in more detail.
And, in the specification you will find the background of some sections such as getAvailability include "This section is not stable." and background text "Unstable".
Upvotes: 1