BLE plugin broken after upgrade to IONIC 3

Hi all,
unfortunately the BLE functionality is giving me a headache after upgrading to IONIC 3.

Before upgrading, I had:

import { BLE } from ‘ionic-native’;

startScanning() {
console.log(‘Scanning Started’);
this.devices = [];
this.isScanning = true;
BLE.startScan([]).subscribe(device => {

Now I had to change to:
import { BLE } from ‘@ionic-native/BLE’;

then adding ble : BLE to my constructor

constructor( private nav: NavController, private mbProvider : MicrobitProvider, public ble : BLE) {

startScanning() {
console.log(‘Scanning Started’);
this.devices = [];
this.isScanning = true;
this.ble.startScan([]).subscribe(device => {

and I also have BLE under “providers” in @NgModule in the file “app.module.ts”.

The error is:

Uncaught (in promise): Error: No provider for BLE!

when I open the page where this code is written.

What could still be missing ?

Although you have it listed in the providers, you have it imported in the app.module.ts file, correct?

I have
import { BLE } from ‘@ionic-native/ble’; in both app.module.ts and in blehome.ts

Fun part is, that I have also a provider which is loaded on startup which imports BLE (but doesn’t use it yet), which doesn’t fail (it is loaded).
Only when the page is called, the error is thrown.

Did you switch to the new page.module.ts system? Since this is a Cordova plugin, I assume you are testing on a device and not in the browser?

I removed all the page.module.ts System as advised.

I have found a workaround though:
If I add (additionally to the described) in app.component.ts

templateUrl: ‘app.html’,
providers: [MicrobitProvider, StatusBar, SplashScreen, BLE]
everything works fine …

Not sure if this behavior is intended though …


Definitely not. You should not need to declare any providers in components.

I also had this problem. I have added import BLE to the app.module.ts file and added the BLE to the providers , solved my issue.

1 Like