Skip to content

Commit

Permalink
Merge pull request #1097 from dotintent/bugfix/Fix-packge-export
Browse files Browse the repository at this point in the history
fix: package export
  • Loading branch information
dominik-czupryna-withintent authored Sep 28, 2023
2 parents 3e25b12 + a6fe5fb commit 22887dd
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"overrides": [
{
"files": ["src/**", "integration-tests/**"],
"files": ["src/**", "__tests__/**", "integration-tests/**"],
"parser": "hermes-eslint",
"extends": [
"plugin:react/recommended",
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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+
Expand Down
1 change: 1 addition & 0 deletions __tests__/BleManager.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
38 changes: 38 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,44 @@ <h2>Creating BLE Manager</h2>
<p>Note that you may experience undefined behaviour when calling a function on one <code>BleManager</code>
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.</p>
<h2>Ask for permissions</h2>
<p>Check if you requested following permissions</p>
<ul>
<li>PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION</li>
<li>PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN (necessary for api 31+ )</li>
<li>PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT (necessary for api 31+ )</li>
</ul>
<p>eg.</p>
<pre class='hljs'>requestBluetoothPermission = <span class="hljs-keyword">async</span> () =&gt; {
<span class="hljs-keyword">if</span> (Platform.OS === <span class="hljs-string">'ios'</span>) {
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>
}
<span class="hljs-keyword">if</span> (Platform.OS === <span class="hljs-string">'android'</span> &amp;&amp; PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION) {
<span class="hljs-keyword">const</span> apiLevel = <span class="hljs-built_in">parseInt</span>(Platform.Version.toString(), <span class="hljs-number">10</span>)

<span class="hljs-keyword">if</span> (apiLevel &lt; <span class="hljs-number">31</span>) {
<span class="hljs-keyword">const</span> granted = <span class="hljs-keyword">await</span> PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
<span class="hljs-keyword">return</span> granted === PermissionsAndroid.RESULTS.GRANTED
}
<span class="hljs-keyword">if</span> (PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN &amp;&amp; PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT) {
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
])

<span class="hljs-keyword">return</span> (
result[<span class="hljs-string">'android.permission.BLUETOOTH_CONNECT'</span>] === PermissionsAndroid.RESULTS.GRANTED &amp;&amp;
result[<span class="hljs-string">'android.permission.BLUETOOTH_SCAN'</span>] === PermissionsAndroid.RESULTS.GRANTED &amp;&amp;
result[<span class="hljs-string">'android.permission.ACCESS_FINE_LOCATION'</span>] === PermissionsAndroid.RESULTS.GRANTED
)
}
}

<span class="hljs-keyword">this</span>.showErrorToast(<span class="hljs-string">'Permission have not been granted'</span>)

<span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>
}</pre>
<h2>Waiting for Powered On state</h2>
<p>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 <code>onStateChange()</code> function:</p>
Expand Down
2 changes: 1 addition & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pre-commit:
commands:
lint:
files: git diff --name-only @{push}
glob: "*.{js,ts,jsx,tsx}"
glob: '*.{js,ts,jsx,tsx}'
run: yarn lint
commit-msg:
parallel: true
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "react-native-ble-plx",
"version": "3.0.0",
"description": "React Native Bluetooth Low Energy library",
"main": "lib/commonjs/index",
"module": "lib/module/index",
"types": "lib/typescript/index.d.ts",
"main": "src/index",
"module": "src/index",
"types": "src/index.d.ts",
"react-native": "src/index",
"source": "src/index",
"files": [
Expand Down
9 changes: 0 additions & 9 deletions scripts/copyExampleProjectFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ const copyExampleProjectJsFiles = () => {
fs.cpSync(jsSourceDirectory, jsSourceDestinationDirectory, { recursive: true })
}

const androidManifestPath = path.join(
__dirname,
EXAMPLE_PROJECT_DIR_NAME,
'android',
'app',
'src',
'main',
'AndroidManifest.xml'
)
const androidManifestDestinationPath = path.join(
__dirname,
TEST_PROJECT_DIR_NAME,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"strict": true,
"target": "esnext",
"verbatimModuleSyntax": true
}
},
"exclude": ["src/**", "__tests__/**", "integration-tests/**"]
}

0 comments on commit 22887dd

Please sign in to comment.