TypeError: navigator.bluetooth.requestLEScan is not a function

This is my first Ionic app so I suspect this is simply an operator error. That said, this operator can’t find the problem so am reaching out to this community for help.

The community pluggin in use:

https://ionicframework.com/docs/native/bluetooth-le

Works fine on iOS (iPhone X and iPad Pro 2017) in debug mode.

Android ( Pixel 4a & Motorola G Power) give the following run time error while debugging:

2021-04-29 12:50:49.042 3941-3941/net.xyzzy.net.gamecenter I/cr_Bluetooth: ChromeBluetoothAdapter created with provided adapterWrapper.

2021-04-29 12:50:49.112 3941-3941/net.xyzzy.net.gamecenter I/Capacitor/Console: File: http://localhost/static/js/main.80cdfffa.chunk.js - Line 1 - Msg: >>> BleClient.initialize() called: result: TypeError: navigator.bluetooth.requestLEScan is not a function

It looks like it’s trying to use the bluetooth support builtin into Chrome instead of using the plugin on Android. What I do notice is the import statement I use:

import { BleClient } from '@capacitor-community/bluetooth-le';

also offers other types such as BluetoothLe so maybe BleClient isn’t the correct object to be calling these static methods on?

Here’s the cap sync output if that’s helpful:

capacitor sync
:heavy_check_mark: Copying web assets from build to android/app/src/main/assets/public in 86.27ms
:heavy_check_mark: Copying native bridge in 1.22ms
:heavy_check_mark: Copying capacitor.config.json in 648.50μp
Found 3 Cordova plugins for android
cordova-plugin-bluetoothle (6.3.1)
cordova-plugin-ionic (5.4.7)
cordova-plugin-whitelist (1.3.4)
:heavy_check_mark: copy in 171.75ms
:heavy_check_mark: Updating Android plugins in 5.82ms
Found 1 Capacitor plugin for android:
@capacitor-community/bluetooth-le (0.6.0)
Found 3 Cordova plugins for android
cordova-plugin-bluetoothle (6.3.1)
cordova-plugin-ionic (5.4.7)
cordova-plugin-whitelist (1.3.4)
:heavy_check_mark: update android in 46.48ms
:heavy_check_mark: Copying web assets from build to ios/App/public in 72.23ms
:heavy_check_mark: Copying native bridge in 566.83μp
:heavy_check_mark: Copying capacitor.config.json in 509.67μp
Found 2 Cordova plugins for ios
cordova-plugin-bluetoothle (6.3.1)
cordova-plugin-ionic (5.4.7)
:heavy_check_mark: copy in 83.00ms
:heavy_check_mark: Updating iOS plugins in 3.77ms
Found 1 Capacitor plugin for ios:
@capacitor-community/bluetooth-le (0.6.0)
Found 2 Cordova plugins for ios
cordova-plugin-bluetoothle (6.3.1)
cordova-plugin-ionic (5.4.7)
:heavy_check_mark: Updating iOS native dependencies with “pod install” (may take several minutes) in 35.68s
Found 1 incompatible Cordova plugin for ios, skipped install
cordova-plugin-whitelist (1.3.4)

Thanks in advance,
George

Solved.

First thing was I had the wrong URL. The one above is for a cordova BLE plugin. The one I’m using is a capacitor community plugin… url below.

AND, it turns out I needed to register the plugin in the main activity for Android as documented here:

https://github.com/capacitor-community/bluetooth-le#android

Onward,
George