Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

Ionic bluetoothSerial problem IOS

$
0
0

I’m using the bluetoothSerial plugin to connect and receive data from a bluetooth device. While i’m testing with Android everything works fine but when i try the same thing in IOS nothing works.

My method to connect to a device is this:

this.bluetoothSerial.isEnabled().then(async res => {
      //Bluetooth encendido
      if(res){
        if(connected){
          const alert = this.alertCtrl.create({
            message: 'Desconectar',
            buttons: [
              {
                role: 'Cancel',
                text:'Cancelar'
              },
              {
                text: 'Desconectar',
                handler: () => {
                  this.bluetoothSerial.disconnect().then(() => {
                    this.bluetooth_service.connected = false;
                  });
                }
              }
            ]
          });
          (await alert).present();
        }else{
          if(this.bluetooth_service.lastDevice !== undefined){
            const loading = await this.loadingCtrl.create({
              message: 'Conectando...'
            });
            loading.present();
            this.bluetoothSerial.connect(this.bluetooth_service.lastDevice).subscribe(success => {
              console.log(success);
              this.bluetooth_service.connected = true;
              this.changes.detectChanges();
              loading.dismiss();
            }, error => {
              loading.dismiss();
              //this.showDevices();
            });
          }else{
            this.showDevices();
          }
        }
      }
    }, async error => {
      //Bluetooth apagado
      const alert = this.alertCtrl.create({
        message: 'Encienda el bluetooth para conectar',
        buttons: [
          {
            role: 'Cancel',
            text:'Aceptar'
          }
        ]
      });
      (await alert).present();
    });

In Xcode the console shows options: with all the methods as if it came empty

Any solution? Thank you!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



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