title: Having Issues with Bluetooth-pulgin in NativeScript: ERROR TypeError: ... is not a function?
body: <p>I am currently trying to learn the Bluetooth connection in NativeScript using this code that I got from Github.<br />
  Everything is fine so far.<br />
  But after I run the app, I get this error message &quot;ERROR TypeError: bluetooth.startScanning is not a function&quot; and now I don't know how to solve this or what the problem is. The error message does not appear for the programmer who programmed this app.</p>
  <p>I would appreciate your help.</p>
  <p>Blutooth.connection.ts</p>
  <pre class="lang-js prettyprint-override"><code>    import { Injectable } from '@angular/core';
      import { BleDevice } from '../models/ble-device.model';
      var bluetooth = require('nativescript-bluetooth');
  
  
      @Injectable()
      export class BluetoothConnection {
        bleDevicesAround: Array&lt;BleDevice&gt; = new Array;
  
        write(bluetoothMessage): void {
            console.log('Writing message: ' + JSON.stringify(bluetoothMessage));
            bluetooth.write(bluetoothMessage)
                .then((result) =&gt; console.log(&quot;Value written &quot; + JSON.stringify(result)),
                (error) =&gt; console.log(&quot;Write error: &quot; + error));
        }
  
        fixPermission(): void {
            bluetooth.hasCoarseLocationPermission()
                .then((granted) =&gt; {
                    console.log(&quot;Has location permission ? &quot; + granted);
  
                    if (!granted) {
                        bluetooth.requestCoarseLocationPermission()
                            .then(() =&gt; console.log(&quot;Location permission requested&quot;));
                    }
                });
        }
  
        connect(UUID: string): Promise&lt;any&gt; {
            return bluetooth.connect({
                UUID: UUID,
                onConnected: (peripheral) =&gt; {
                    console.log(&quot;Periperhal connected with UUID: &quot; + peripheral.UUID);
                    peripheral.services.forEach(function (service) {
                        console.log(&quot;Service found: &quot; + JSON.stringify(service));
                    });
                },
                onDisconnected: (peripheral) =&gt; {
                    console.log(&quot;Periperhal disconnected with UUID: &quot; + peripheral.UUID)
                }
            });
        }
  
        disconnect(UUID: string): void {
            bluetooth.disconnect({ UUID: UUID })
                .then(() =&gt; console.log(&quot;Disconnected successfully&quot;),
                (err) =&gt; console.log(&quot;Disconnection error: &quot; + err));
        }
  
        scan() {
            console.log('Scanning...');
            this.bleDevicesAround = new Array;
           
              return bluetooth.startScanning({
                  serviceUUIDs: [],
                  seconds: 3,
                  onDiscovered: (device) =&gt; {
                      const bleDevice = new BleDevice(device.UUID, device.name, device.state);
                      this.bleDevicesAround.push(bleDevice);
                  }
              });
        }
      }
  </code></pre>
  <p>where the method is used:</p>
  <pre class="lang-js prettyprint-override"><code>bleDevicesAround: Array&lt;BleDevice&gt; = new Array;
  connectToMagicBlue() {
              this.bluetoothService.scan().then(() =&gt; {
                  console.log('Scanning completed');
                  this.magicBlue = this.getMagicBlue();
                  if (this.magicBlue) {
                      console.log('Magic blue found');
                      this.bluetoothService.connect(this.magicBlue.UUID)
                          .then((device) =&gt; console.log('Connected: ' + JSON.stringify(device)));
                  } else {
                      console.log('Device not found');
                  }
              });
      }
  </code></pre>