Skip to content

Commit

Permalink
Android: Move Android permissions to config.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximBelov committed Sep 26, 2024
1 parent 3267a78 commit 7544932
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
= 0.9.15 =
Android: Move Android permissions to config.xml

= 0.9.14 =
iOS: Add plugin variables

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ All variables can be modified after installation by updating the values in `pack

- `IOS_INIT_ON_LOAD`: [**iOS**] Prevents the Bluetooth plugin from being initialised until first access to the `bluetoothClassicSerial` window object. This allows an application to warn the user before the Bluetooth access permission is requested.

## Android permission

To include the default set of permissions the plugin installs on Android SDK v33+, add the following snippet in your `config.xml` file, in the `<platform name="android">` section:

```xml
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="34" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="33" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="33" />
</config-file>
```

For the best understanding about which permissions are needed for which combinations of target SDK version & OS version, see [Android Bluetooth permissions](https://developer.android.com/guide/topics/connectivity/bluetooth/permissions)

## Ionic

$ npm i @awesome-cordova-plugins/bluetooth-classic-serial-port
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-bluetooth-classic-serial-port",
"version": "0.9.14",
"version": "0.9.15",
"description": "Cordova Bluetooth Serial Port Profile Communication Plugin",
"cordova": {
"id": "cordova-plugin-bluetooth-classic-serial-port",
Expand Down
11 changes: 1 addition & 10 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-bluetooth-classic-serial-port"
version="0.9.14">
version="0.9.15">

<name>Bluetooth Classic Serial</name>
<description>Bluetooth Serial Communication Plugin</description>
Expand All @@ -29,15 +29,6 @@
<source-file src="src/android/nz/co/soltius/cordova/BluetoothClassicSerialService.java"
target-dir="src/nz/co/soltius/cordova"/>

<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="34" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="33" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="33" />
</config-file>

</platform>

<platform name="ios">
Expand Down
2 changes: 1 addition & 1 deletion www/bluetoothClassicSerial.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*global cordova*/
module.exports = {

version: '0.9.14',
version: '0.9.15',

connect: function (deviceId, interfaceArray, success, failure) {

Expand Down

0 comments on commit 7544932

Please sign in to comment.