1.0.0 • Published 4 years ago

capacitor-bluetooth-paired-devices v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Capacitor Bluetooth Serial Plugin

A client implementation for interacting with Bluetooth

Supported platforms

  • Web
  • Android
  • iOS

Usage

Install the plugin via npm

npm install --save capacitor-bluetooth-paired-devices

In your capacitor project, make sure to register the Android plugin in in the projects MainActivity as follows

import com.capacitor.paired.BluetoothPairedDevices;

public class MainActivity extends BridgeActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
            add(BluetoothPairedDevices.class);
        }});
    }
}

Use from app

import {Plugins} from "@capacitor/core";

const { BluetoothPairedDevices } = Plugins;

BluetoothPairedDevices.getPairedDevices()
  .then((result: PairedDevices) => {
  /* 
   * {
   *   devices: [{
   *     name: 'device1',
   *     address: '00:00:00:00:01'
   *   }, {
   *     name: 'device2',
   *     address: '00:00:00:00:02'
   *   }]
   * }
   */
  })