diff --git a/.eslintrc.json b/.eslintrc.json index 591771fd..f278966f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,7 +8,7 @@ }, "overrides": [ { - "files": ["src/**", "integration-tests/**"], + "files": ["src/**", "__tests__/**", "integration-tests/**"], "parser": "hermes-eslint", "extends": [ "plugin:react/recommended", diff --git a/README.md b/README.md index c4e6616a..e0dc4652 100644 --- a/README.md +++ b/README.md @@ -40,21 +40,27 @@ It does NOT support: ## Compatibility -This version (2.x) breaks compatibility with old RN versions. Please check [old README](./docs/README_V1.md) (1.x) +For old RN versions (<0.60) please check [old README](./docs/README_V1.md) (1.x) for the old instructions or [migration guide](./docs/MIGRATION_V1.md). -| React Native | 2.0.0 | +| React Native | 3.0.0 | | ------------ | ------------------ | -| 0.63.3 | :white_check_mark: | -| 0.62.2 | :white_check_mark: | -| 0.61.5 | :white_check_mark: | -| 0.60.6 | :white_check_mark: | +| 0.72.4 | :white_check_mark: | +| 0.71.13 | :white_check_mark: | +| 0.70.13 | :white_check_mark: | ## Recent Changes -**2.0.3** +**3.0.0** -- Updated MultiplatformBleAdapter to version 0.1.9 +- Added Example project +- Updated MultiplatformBleAdapter to version 0.2.0. +- Updated RN bridge config +- Changed CI flow +- Updated CI to RN 0.72.x +- Updated docs +- Updated dependencies +- Fixed iOS 16 bugs [Current version changes](CHANGELOG.md) [All previous changes](CHANGELOG-pre-03.md) @@ -69,8 +75,6 @@ Interested in React Native project involving Bluetooth Low Energy? [We can help Contact us at [intent](https://withintent.com/contact-us/?utm_source=github&utm_medium=github&utm_campaign=external_traffic). -Contact us at [Gitter](https://gitter.im/RxBLELibraries/react-native-ble) if you have any questions, feedback or want to help! - ## Configuration & Installation ### Expo SDK 43+ diff --git a/__tests__/BleManager.js b/__tests__/BleManager.js index 6fd050cb..8e939606 100644 --- a/__tests__/BleManager.js +++ b/__tests__/BleManager.js @@ -1,3 +1,4 @@ +/* eslint-disable no-import-assign */ import { BleManager, Device, Service, Characteristic } from '../src' import { BleErrorCode, BleErrorCodeMessage } from '../src/BleError' import * as Native from '../src/BleModule' diff --git a/docs/index.html b/docs/index.html index 16ec03d6..798ab7c3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1968,6 +1968,44 @@
Note that you may experience undefined behaviour when calling a function on one BleManager
and continuing with another instance. A frequently made error is to create a new instance
of the manager for every re-render of a React Native Component.
Check if you requested following permissions
+eg.
+requestBluetoothPermission = async () => {
+ if (Platform.OS === 'ios') {
+ return true
+ }
+ if (Platform.OS === 'android' && PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION) {
+ const apiLevel = parseInt(Platform.Version.toString(), 10)
+
+ if (apiLevel < 31) {
+ const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
+ return granted === PermissionsAndroid.RESULTS.GRANTED
+ }
+ if (PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN && PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT) {
+ const result = await PermissionsAndroid.requestMultiple([
+ PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,
+ PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
+ PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
+ ])
+
+ return (
+ result['android.permission.BLUETOOTH_CONNECT'] === PermissionsAndroid.RESULTS.GRANTED &&
+ result['android.permission.BLUETOOTH_SCAN'] === PermissionsAndroid.RESULTS.GRANTED &&
+ result['android.permission.ACCESS_FINE_LOCATION'] === PermissionsAndroid.RESULTS.GRANTED
+ )
+ }
+ }
+
+ this.showErrorToast('Permission have not been granted')
+
+ return false
+}
When iOS application launches BLE stack is not immediately available and we need to check its status.
To detect current state and following state changes we can use onStateChange()
function: