user450463
user450463

Reputation: 21

cordova-plugin-bluetoothle stops being able to discover devices when packaged into an APK

The plugin is working perfectly when running:

ionic cordova run android --device

To deploy to a device from my computer.

However, if we run:

ionic cordova build --debug android

To make an APK, and then when we install the APK scanning happens just fine (from startScan method we get status: scanStarted), but no device is ever discovered ( we never get: status:scanResult).

I should also note that the standard BLE plugin (cordova-plugin-ble-central) is able to discover devices when in an APK. However, that plugin has its own issues that have made it not viable for us to use.

Has anyone encountered this before or has any suggestions?

I am testing on a Samsung Galaxy A Tablet with Android Version 7.0.

We are building our application in Ionic. Here are some entries from package.json so you can see what versions we are running:

"@angular/core": "^5.2.3", "@ionic-native/core": "4.7.0", "cordova-android": "7.0.0",

Thanks very for any help you can offer.

Will

Upvotes: 1

Views: 1203

Answers (1)

user450463
user450463

Reputation: 21

We were able to solve this problem. It turns out that https://github.com/randdusing/cordova-plugin-bluetoothle#requestpermission must be called when the application is packaged into an APK. It's not an issue when using ionic cordova run android, however.

Not sure why there is a difference, but that is the fix.

Upvotes: 1

Related Questions