Ionic 3 Bluetooth serial not working

I’m new in Ionic so I’m just testing what’s possible. I’m trying just to check if bluetooth is enabled/disabled in iphone 8. I did everything by documentation Ionic Bluetooth-Serial but I can’t get it work. It always says bluetooth is disabled.

I put module & register provider in app.modules.ts Then in my home.ts I have following:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';

   selector: 'page-home',
   templateUrl: 'home.html'
export class HomePage {
   constructor(public navCtrl: NavController, private bluetoothSerial: BluetoothSerial) {

    let TIME_IN_MS = 2000;
    let hideFooterTimeout = setTimeout( () => {
         this.bluetoothSerial.isEnabled().then(function () {
              alert('Bluetooth enabled');
          }, function () {
              alert('Bluetooth disabled');
    }, TIME_IN_MS);

I tried to put there timeout but it didn’t help. I’m running it on iPhone by xCode… Any advice what’s wrong?

@svkmedia isEnabled() in bluetooth serial only reports you if your device bluetooth is enabled or not. If you want to check and if it’s disabled and you want to enable it, then you should try first isEnabled() then you should check device settings to enable it using enable(). This will enable Bluetooth on the device.

As in your question you’ve mentioned that it always says bluetooth is disabled. have you tried turning on your device bluetooth manually and then check if it’s enabled or not?

@Heenavora thank you for your answer. Yes I just want to know if bluetooth is enabled. But even when it’s enabled in iPhone settings my app says it’s disabled… So really don’t know what’s wrong.

can you check what error it throws?

let hideFooterTimeout = setTimeout( () => {
         this.bluetoothSerial.isEnabled().then(success => {
              alert('Bluetooth enabled');
          }, error => {
              alert(error);// or alert(JSON.stringify(error));
    }, TIME_IN_MS);

I think this will help you know the root for error.

@Heenavora I did and I’m getting alert with number 4. Nothing else. I don’t know what this mean.

Hi, @svkmedia

This code put in your app.component file when platform is ready.

this.bluetoothSerial.isEnabled().subscribe(() => {
	alert('Bluetooth enabled');

Thank you.

@addwebsolution it’s not working with your code

Uncaught (in promise): TypeError: undefined is not an object (evaluating ‘_this.bluetoothSerial.isEnabled’) http://localhost:8100/build/main.js:317:34 onInvoke@http://localhost:8100/build/vendor.js:5134:39 run@http://localhost:8100/build/polyfills.js:3:10149 http://localhost:8100/build/polyfills.js:3:20245 onInvokeTask@http://localhost:8100/build/vendor.js:5125:43 runTask@http://localhost:8100/build/polyfills.js:3:10844 o@http://localhost:8100/build/polyfills.js:3:7901 invokeTask@http://localhost:8100/build/polyfills.js:3:16824 p@http://localhost:8100/build/polyfills.js:2:27654 v@http://localhost:8100/build/polyfills.js:2:27894