Skip to content

Commit

Permalink
Updated 'Configuration & Installation' steps for autolinked app (doti…
Browse files Browse the repository at this point in the history
…ntent#807)

It seems that three steps are not needed for iOS (link, adding an empty swift file and podfile update). For Android one step is not needed (link) and the last is optional (uses-permission clauses are added by manifest merger and uses-feature is optional).
  • Loading branch information
dariuszseweryn authored Jun 8, 2021
1 parent 1c3ceca commit a2c9761
Showing 1 changed file with 35 additions and 45 deletions.
80 changes: 35 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,66 +73,56 @@ Contact us at [Gitter](https://gitter.im/RxBLELibraries/react-native-ble) if you
### Expo

1. Make sure your Expo project is ejected (formerly: detached). You can read how to do it [here](https://docs.expo.io/versions/latest/expokit/eject/) and [here](https://docs.expo.io/versions/latest/expokit/expokit). (only for expo)
2. Follow steps for iOS/Android.
1. Follow steps for iOS/Android.

### iOS ([example setup](https://github.com/Cierpliwy/SensorTag))

1. `npm install --save react-native-ble-plx`
2. `npx react-native link react-native-ble-plx`
3. Open Xcode workspace located inside `ios` folder and add empty Swift file if you don't have at least one:
- Select File/New/File...
- Choose Swift file and click Next.
- Name it however you want, select your application target and create it.
- Accept to create Objective-C bridging header.
4. Update your `ios/Podfile` to contain (it may be already there):
```
pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
```
5. Enter `ios` folder and run `pod update`
6. Add `NSBluetoothAlwaysUsageDescription` in `info.plist` file. (it is a requirement since iOS 13)
7. If you want to support background mode:
1. Enter `ios` folder and run `pod update`
1. Add `NSBluetoothAlwaysUsageDescription` in `info.plist` file. (it is a requirement since iOS 13)
1. If you want to support background mode:
- In your application target go to `Capabilities` tab and enable `Uses Bluetooth LE Accessories` in
`Background Modes` section.
- Pass `restoreStateIdentifier` and `restoreStateFunction` to `BleManager` constructor.

### Android ([example setup](https://github.com/Cierpliwy/SensorTag))

1. `npm install --save react-native-ble-plx`
2. `npx react-native link react-native-ble-plx`
3. In top level `build.gradle` make sure that min SDK version is at least 18:
```groovy
buildscript {
ext {
...
minSdkVersion = 18
...
```
4. In `build.gradle` make sure to add jitpack repository to known repositories:

```groovy
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
1. In top level `build.gradle` make sure that min SDK version is at least 18:

```groovy
buildscript {
ext {
...
minSdkVersion = 18
...
```
1. In `build.gradle` make sure to add jitpack repository to known repositories:
```groovy
allprojects {
repositories {
...
maven { url 'https://www.jitpack.io' }
}
}
}
```
5. In `AndroidManifest.xml`, add Bluetooth permissions and update `<uses-sdk/>`:
```
1. (Optional) In `AndroidManifest.xml`, add Bluetooth permissions and update `<uses-sdk/>`:
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Add this line if your application always requires BLE. More info can be found on:
https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions
-->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<!-- Add this line if your application always requires BLE. More info can be found on:
https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions
-->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
...
```
...
```
## Troubleshooting
Expand Down

0 comments on commit a2c9761

Please sign in to comment.