[SOLVE] Problem using BLE


Hello! Im using BLE in my new project and when I do “Ionic serve” there are no error in the terminal but when run the web I can see this error:

Runtime Error
Uncaught (in promise): Error: No provider for BLE! d"http://localhost:8100/build/plyfills.js:3:3996 injectionError@http://localhost:8100/build/main.js:1509:91

In my project I ran this command:
$ ionic plugin add --save cordova-plugin-ble-central
$ npm install --save @ionic-native/ble

and in my home.ts I have:
import { BLE } from ‘@ionic-native/ble’;

constructor(private ble: BLE) {… }

Somebody know how to fix my problem?
Thank in advance!!


To use the BLE plugin you need to run your app on physical device, not in the web.

Also have you included BLE in the array of providers in app.module.ts


Thank for reply me @kgaspbar, my array of providers in my app.module.ts is like this:

providers: [
{provide: ErrorHandler, useClass: IonicErrorHandler}

what I need to include? Thank in advance!!

providers: [
    {provide: ErrorHandler, useClass: IonicErrorHandler}

And then use it as you would. But for it to work you need to run it on a physical device.


Ok! after update the array of providers I have this error:

Starting app-scripts server: --port 8100 --livereload-port 35729 --address - Ctrl+C to cancel
[10:26:41] watch started …
[10:26:41] build dev started …
[10:26:41] clean started …
[10:26:41] clean finished in 2 ms
[10:26:41] copy started …
[10:26:41] transpile started …
[10:26:43] typescript: src/app/app.module.ts, line: 38
Cannot find name ‘BLE’.

  L37:  providers: [
  L38:    BLE,
  L39:    StatusBar,

[10:26:43] dev server running: http://localhost:8100/

[10:26:43] copy finished in 2.12 s
[10:26:43] watch ready in 2.15 s

Do you know where is the problem now?


Need to import it in app.module.ts ofc :slight_smile:

import { BLE } from '@ionic-native/ble';


Hahaha yeeeeeess!! Now work fine! Really thank you man!:sunglasses: