Skip to content

Commit

Permalink
Merge pull request #629 from Polidea/prepare_2_0_release
Browse files Browse the repository at this point in the history
Prepare 2.0 release
  • Loading branch information
Cierpliwy authored Apr 15, 2020
2 parents 70e25cd + be830d1 commit 10d3be8
Show file tree
Hide file tree
Showing 40 changed files with 8,618 additions and 2,904 deletions.
7 changes: 3 additions & 4 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ node_modules/warning/.*
[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/interface.js
node_modules/react-native/flow/

[options]
Expand All @@ -39,9 +39,8 @@ module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
Expand Down Expand Up @@ -75,4 +74,4 @@ untyped-import
untyped-type-import

[version]
^0.105.0
^0.113.0
35 changes: 14 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ _ios_job_template: &ios_job_template
<<: *integration_job_template
language: objective-c
os: osx
osx_image: xcode10.1
osx_image: xcode11.4
xcode_project: integration-tests/Setup/ios/Setup.xcodeproj
xcode_scheme: Setup
xcode_destination: platform=iOS Simulator
# before_script will make project
script:
- integration-tests/scripts/build-ios-project integration-tests/Setup
- travis_wait 30 integration-tests/scripts/build-ios-project integration-tests/Setup

matrix:
include:
Expand All @@ -98,29 +98,22 @@ matrix:
# Integration tests for different React Native versions

- <<: *android_job_template
name: 'Integrate with RN 0.60.5 Android'
env: RN_VERSION=0.60.5
name: 'Integrate with RN 0.62.2 Android'
env: RN_VERSION=0.62.2
- <<: *ios_job_template
name: 'Integrate with RN 0.60.5 iOS'
env: RN_VERSION=0.60.5
name: 'Integrate with RN 0.62.2 iOS'
env: RN_VERSION=0.62.2

- <<: *android_job_template
name: 'Integrate with RN 0.59.10 Android'
env: RN_VERSION=0.59.10
name: 'Integrate with RN 0.61.5 Android'
env: RN_VERSION=0.61.5
- <<: *ios_job_template
name: 'Integrate with RN 0.59.10 iOS'
env: RN_VERSION=0.59.10
name: 'Integrate with RN 0.61.5 iOS'
env: RN_VERSION=0.61.5

- <<: *android_job_template
name: 'Integrate with RN 0.58.6 Android'
env: RN_VERSION=0.58.6
name: 'Integrate with RN 0.60.6 Android'
env: RN_VERSION=0.60.6
- <<: *ios_job_template
name: 'Integrate with RN 0.58.6 iOS'
env: RN_VERSION=0.58.6

- <<: *android_job_template
name: 'Integrate with RN 0.57.8 Android'
env: RN_VERSION=0.57.8
- <<: *ios_job_template
name: 'Integrate with RN 0.57.8 iOS'
env: RN_VERSION=0.57.8
name: 'Integrate with RN 0.60.6 iOS'
env: RN_VERSION=0.60.6
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
**2.0.0**

- Update direct dependency to Multiplatform Ble Adapter
- Remove support for RN version < 0.60
- Fixed Typescript `callbackType` type definition.

**1.1.1**

- Update development dependencies
Expand Down
107 changes: 38 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## About this library

This is React Native Bluetooth Low Energy library using [RxBluetoothKit](https://github.com/Polidea/RxBluetoothKit) and [RxAndroidBle](https://github.com/Polidea/RxAndroidBle) under the hood.
This is React Native Bluetooth Low Energy library wrapping [Multiplatform Ble Adapter](https://github.com/Polidea/MultiPlatformBleAdapter/).

It supports:

Expand All @@ -24,34 +24,30 @@ It supports:
- [background mode on iOS](https://github.com/Polidea/react-native-ble-plx/wiki/Background-mode-(iOS))
- turning the device's Bluetooth adapter on

What this library does NOT support:
It does NOT support:

- bluetooth classic devices.
- communicating between phones using BLE (Peripheral support)
- [bonding peripherals](https://github.com/Polidea/react-native-ble-plx/wiki/Device-Bonding)

## Compatibility

| React Native | 1.0.3 | 1.1.0 |
| ------------- | ------------------------------ | ------------------------------ |
| 0.60.5 | :white_check_mark:<sup>2</sup> | :white_check_mark:<sup>2</sup> |
| 0.59.10 | :white_check_mark: | :white_check_mark: |
| 0.58.6 | :white_check_mark: | :white_check_mark: |
| 0.57.8 | :white_check_mark: | :white_check_mark: |
| 0.56.1 | :boom:<sup>1</sup> | :boom:<sup>1</sup> |
| 0.55.4 | :boom:<sup>1</sup> | :boom:<sup>1</sup> |
This version (2.x) breaks compatibility with old RN versions. Please check [old README](./docs/README_V1.md) (1.x)
for the old instructions or [migration guide](./docs/MIGRATION_V1.md).

<sup>1</sup> fails on Android, although might work after updating gradle

<sup>2</sup> may require usage of `jetifier` on Android and migration to `CocoaPods` on iOS.
| React Native | 2.0.0 |
| ------------- | ------------------------------ |
| 0.62.2 | :white_check_mark: |
| 0.61.5 | :white_check_mark: |
| 0.60.6 | :white_check_mark: |

## Recent Changes

**1.1.1**
**2.0.0**

- Update development dependencies
- Add more information to the README and INTRO file.
- Remove `const` from enum types in the typescript definition file.
- Add backpressure buffer for notifications.
- Update direct dependency to Multiplatform Ble Adapter
- Remove support for RN version < 0.60
- Fixed Typescript `callbackType` type definition.

[All previous changes](CHANGELOG.md)

Expand All @@ -63,73 +59,58 @@ Interested in React Native project involving Bluetooth Low Energy? [We can help

[Learn more about Polidea's BLE services](https://www.polidea.com/services/ble/?utm_source=Github&utm_medium=Npaid&utm_campaign=Tech_BLE&utm_term=Code&utm_content=GH_NOP_BLE_COD_RNB001).

Documentation can be found [here](https://polidea.github.io/react-native-ble-plx/).
[Documentation can be found here](https://polidea.github.io/react-native-ble-plx/).

Contact us at [Polidea](https://www.polidea.com/project/?utm_source=Github&utm_medium=Npaid&utm_campaign=Kontakt&utm_term=Code&utm_content=GH_NOP_KKT_COD_RNB001).

Contact us at [Gitter](https://gitter.im/RxBLELibraries/react-native-ble) if you have any questions, feedback or want to help!

## Configuration & Installation

### iOS (expo/Podfile and RN 0.60+, [example setup](https://github.com/Cierpliwy/SensorTagExpo))
### 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.

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

1. Make sure your Expo project is ejected (formerly: detached). You can read how to do it [here](https://docs.expo.io/versions/v32.0.0/expokit/eject/) and [here](https://docs.expo.io/versions/latest/expokit/expokit). (only for expo)
2. `npm install --save react-native-ble-plx`
3. `react-native link react-native-ble-plx`
4. Open Xcode workspace located inside `ios` folder and add empty Swift file if you don't have at least one:
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.
5. Update your `ios/Podfile` to contain:
4. Update your `ios/Podfile` to contain (it may be already there):
```
pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
```
6. Enter `ios` folder and run `pod update`
7. Minimal supported version of iOS is 8.0
8. If you want to support background mode:
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:
- 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.
9. Starting from iOS 13 add `NSBluetoothAlwaysUsageDescription` in `info.plist` file.

### iOS (react-native < 0.60, [example setup](https://github.com/Cierpliwy/SensorTag/tree/rn59))

1. `npm install --save react-native-ble-plx`
2. `react-native link react-native-ble-plx`
3. Open Xcode project 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 targets and create it.
- Accept to create Objective-C bridging header.
4. Minimal supported version of iOS is 8.0
5. 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.
6. Starting from iOS 13 add `NSBluetoothAlwaysUsageDescription` in `info.plist` file.

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

1. `npm install --save react-native-ble-plx`
2. `react-native link react-native-ble-plx`
3. In `build.gradle` of `app` module make sure that min SDK version is at least 18:

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
android {
...
defaultConfig {
minSdkVersion 18
buildscript {
ext {
...
minSdkVersion = 18
...
```
4. In `build.gradle` of `app` module make sure to add jitpack repository to known repositories:
4. In `build.gradle` make sure to add jitpack repository to known repositories:

```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
maven { url 'https://www.jitpack.io' }
}
}
```
Expand All @@ -140,28 +121,16 @@ allprojects {
...
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<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"/>

<uses-sdk
android:minSdkVersion="18"
...
...
```

6. If you are using AndroidX, then for the time being you need to convert import statements in the Android library with [jetifier](https://www.npmjs.com/package/jetifier). These steps apply for all react-native packages, which are during the transition period:

- `npm install --save-dev jetifier`
- Run `jetify` script after `npm install`. You can do it by adding "postinstall" script to the `package.json` file:
```json
...
"postinstall": "npx jetify",
...
```

## Troubleshooting

### Problems with Proguard
Expand Down
3 changes: 0 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0'
}
}

apply plugin: 'com.android.library'
apply plugin: 'groovyx.android'

android {
compileSdkVersion safeExtGet('compileSdkVersion', 27)
Expand Down Expand Up @@ -49,5 +47,4 @@ repositories {
dependencies {
implementation "com.facebook.react:react-native:+"
implementation 'com.github.Polidea:MultiPlatformBleAdapter:58c87b49f12f4a5ab6f7af31f8085249e206400a'
testImplementation 'org.robospock:robospock:1.0.1'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.polidea.reactnativeble;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.polidea.reactnativeble.converter;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableArray;
Expand Down
Loading

0 comments on commit 10d3be8

Please sign in to comment.