Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71530

Diagnostic not working

$
0
0

@theetje wrote:

Hi all,

I am working on an app and would like to check if Bluetooth is on before trying to collect data. Now I tried using the ionic diagnostic plugin as given here. And added the usual this to the app.module.ts:

import { Diagnostic } from '@ionic-native/diagnostic/ngx';
...
providers: [
...
        Diagnostic,
    ]
...

The plugin is installed and shows after running the ionic cordova list command. But in-app it keeps on running into the Uncaught (in promise): TypeError: object is not a function TypeError: object is not a function at Diagnostic.BluetoothAvailable

I am calling the following function from a provider in a different provider:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Diagnostic } from '@ionic-native/diagnostic/ngx';
import { Platform } from 'ionic-angular';

/*
  Generated class for the DiagnosticProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class DiagnosticProvider {

    constructor(
        public http: HttpClient,
        private diagnostic: Diagnostic,
        private platform: Platform,
    ) {
            console.log('Hello DiagnosticProvider Provider');
    }
 
    public checkBluetooth() {
        console.log("in checkBluetooth");
        this.platform.ready().then(() =>{
            let successCallback = (isAvailable) => { console.log('Is available? ' + isAvailable); }
            let errorCallback = (e) => console.error(e);
            console.log("works");
            this.diagnostic.isBluetoothAvailable().then(successCallback).catch(errorCallback);
        });
    }
}


Ionic:

   ionic (Ionic CLI)  : 4.10.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.10

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 9 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/thomas/Android/Sdk)
   NodeJS            : v8.11.4 (/usr/bin/node)
   npm               : 5.8.0
   OS                : Linux 4.18

Also, I tried ionic repair and removing all node_modules and reinstalling them.

Any ideas on how to tackle this

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71530

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>