manekinekko / angular-web-bluetooth

The missing Web Bluetooth module for Angular
https://manekinekko.github.io/angular-web-bluetooth/
MIT License
196 stars 59 forks source link

Angular app cannot open in unsupported browser #80

Closed Vadalarm-IT-Admin closed 2 years ago

Vadalarm-IT-Admin commented 2 years ago

I use the angulat-web-bluetooth package in my Angular project, however if I open it in Safari then I only see a white screen with the following console message: Error: Uncaught (in promise): Error: Your browser does not support Smart Bluetooth. See http://caniuse.com/#search=Bluetooth for more details. I would like to to open the web app even if the browser is not supported and the web bluetooth can't be used. What can i do in such a case? @manekinekko

manekinekko commented 2 years ago

Hey @Vadalarm-IT-Admin you can first check if Web BLE is supported by the browser. Here is an example:

function isWebBluetoothEnabled() {
  return navigator.bluetooth;
}
Vadalarm-IT-Admin commented 2 years ago

I have skipped the dependency injection in case of the BluetoothCore, I have created new BluetoothCore object in a function:

let ble: BluetoothCore = new BluetoothCore(
      new BrowserWebBluetooth(),
      console
);