Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property bluetooth does not exist on type ‘Navigator'

I integrated sample code into my Angular 6 project. But there some compile errors. One of these errors is: Property 'bluetooth' does not exist on type 'Navigator'.

Why this error happens and how can I solve it?

like image 301
affeto Avatar asked Dec 10 '22 06:12

affeto


1 Answers

Use this below module to install types of web-bluetooth api. Which you can use to define types of navigator blutooth api objects.

https://www.npmjs.com/package/@types/web-bluetooth

Now if you need not specify the exact type of navigator object (& its properties) then you can do following:

let mobileNavigatorObject: any = window.navigator;
if(mobileNavigatorObject && mobileNavigatorObject.bluetooth) {
  // Here write your logic of mobileNavigatorObject.bluetooth.requestDevice();
}
like image 154
Shantanu Avatar answered Feb 12 '23 01:02

Shantanu