@arronar wrote:
Hi there!
I just arrived to Ionic framework because I’m using angular framework and I wanted to build a simple bluetooth application. My problem is that while I have used both BLE and BluetoothLE plugins, when trying to install my app I got no warning that the current app is using bluetooth and needs my permissions to use it.The target Android version that I want to use is the 9 and thus I installed the 28 Android SDK and added the following lines to my config.xml
<platform name="android"> <preference name="android-minSdkVersion" value="27" /> <preference name="android-targetSdkVersion" value="28" /> ...
The I installed the BLE plugin using the commands that docs suggest and after running them I realized that there was no corresponding plugin entry to the config.xml (Is that expected). So I added on at the end like this
<plugin name="cordova-plugin-ble-central" spec="1.2.4" />
Then I imported at one of my modules the following line
import { BLE } from '@ionic-native/ble/ngx';
and I added the BLE also to the providers list of the same module.Finally I created a service of mine which is imported at a specific page and contains:
import { Injectable } from '@angular/core'; import { LogsService } from '@services/logs.service'; import { BLE } from '@ionic-native/ble/ngx'; @Injectable({ providedIn: 'root' }) export class BluetoothService { constructor( private logs: LogsService, private ble: BLE ) { this.initializeBluetooth(); } initializeBluetooth() { this.logs.add('initializing BLE...'); this.ble.scan([], 5) .subscribe( device => this.logs.add(JSON.stringify(device)), error => this.logs.add(JSON.stringify(error)) ); } }
I tried the same with BluetoothLE plugin with some changes in the config.xml and the service files.
At the end I’m running
ionic cordova build android --debug
to produce an apk file that I’m using it to install it to my device (Samsung A20e)At logs I can see the Initializing BLE… text but nothing else. Never asked for bluetooth permissions or to turn it on.
So am I missing something? Am I doing something that wrong? I tried many different combinations in order to figure out what is happening but no luck so far.
Any idea or suggestion would be appreciated.
Posts: 1
Participants: 1