2
votes

i need an help. So i've created ionic cordova with angular project to make an app. I've launched the app on Android device and starts debugging with Chrome DevTools.

So everything works, but, the problem is:

I've installed this BLE ionic plugin:

https://ionicframework.com/docs/native/ble#installation

Insert this:

ionic cordova plugin add cordova-plugin-ble-central
npm install @ionic-native/ble

Added this on app.module.ts

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

    @NgModule({
  declarations: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    BLE <------- Add this BLE on providers
  ]
})

So this is my home.ts

    import { Component, OnInit } from '@angular/core';
import { NavController } from 'ionic-angular';
import { BLE } from '@ionic-native/ble/ngx';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage implements OnInit{

  constructor(
    public navCtrl: NavController,
    public ble: BLE
    ) {

  }

  ngOnInit() {
    this.ble.startScan([]).subscribe(device => {
      console.log(JSON.stringify(device));
      debugger;
    });

    setTimeout(() => {
      this.ble.stopScan();
    }, 5000);
  }

}

i've launch this by terminal:

ionic cordova run android -l

and when the app starts the error is:

ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function TypeError: Object(...) is not a function at BLE.startScan (vendor.js:81070) at HomePage.webpackJsonp.251.HomePage.ngOnInit (main.js:178) at checkAndUpdateDirectiveInline (vendor.js:13047) at checkAndUpdateNodeInline (vendor.js:14571) at checkAndUpdateNode (vendor.js:14514) at debugCheckAndUpdateNode (vendor.js:15407) at debugCheckDirectivesFn (vendor.js:15348) at Object.eval [as updateDirectives] (ng:///AppModule/HomePage_Host.ngfactory.js:9) at Object.debugUpdateDirectives [as updateDirectives] (vendor.js:15333) at checkAndUpdateView (vendor.js:14480) at c (polyfills.js:3) at c (polyfills.js:3) at polyfills.js:3 at t.invokeTask (polyfills.js:3) at Object.onInvokeTask (vendor.js:5387) at t.invokeTask (polyfills.js:3) at r.runTask (polyfills.js:3) at o (polyfills.js:3) defaultErrorLogger @ vendor.js:2085

Whats i've wrong, or i've forget something ? This problem happens on every plugins i've used.

1
try removing platform android and reinstalling it. That usually solves these kind of problems, I have noticed. - AJT82
@AJT_82 i've tried but nothing. - Mr. Developer
can you do ionic info and share what versions u have? - Sergey Rudenko

1 Answers

0
votes

you have to pass two parameter in startScan([],15)