For the complete documentation index, see llms.txt. This page is also available as Markdown.

Android Bluetooth API

Connect to Bluetooth devices using the WebToNative JavaScript API. Invoke functions to scan, pair, and upair to available Bluetooth devices from the app.

You'll need to import the JavaScript file into your website before starting from this link.

const { Bluetooth } = window.WTN

//To start scanning for bluetooth devices
Bluetooth.startBluetoothScan({
    callback: function(data){
        //Contains data which has a list of available bluetooth devices
    }
})


//To connect bluetooth device with specific address
Bluetooth.pairDevice({
    address, //Device address that you want to connect
    timeout, //Time till the app should try to connect before returning not paired status
    callback: function(data){
        //Contains data which has result as PAIRED | NOT_PAIRED
    }
})


//To disconnect from the connected bluetooth device
Bluetooth.unpairDevice({
    address, //Device address that you want to connect
    callback: function(data){
        //Contains data which has result UNPAIRED | ERROR DURING UNPAIRING
    }
})

Last updated