diff --git a/CHANGELOG.md b/CHANGELOG.md index e4ce27bf..9a9437bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 3.0.0-beta + +* **BREAKING** Migrate Android implementation to RxAndroidBle2 + This might require the user to implement a global error handler https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling + See more: https://github.com/Polidea/RxAndroidBle/wiki/FAQ:-UndeliverableException + ## 2.3.1 * Fix connection timeout on iOS diff --git a/README.md b/README.md index 84d6651b..ddcfbdd9 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,46 @@ Support for Bluetooth Low Energy has been added in API 18, hence the library req **Notice:** You don't need to add any permissions related to BLE to the `AndroidManifest.xml`, because they are already declared in the library's native module. However, you still need to request `ACCESS_FINE_LOCATION` permission at runtime to be able to scan for peripheral. See [example's code](https://github.com/Polidea/FlutterBleLib/blob/202c6fe48300be207f80567ca4bee5b6fbc83eb5/example/lib/devices_list/devices_bloc.dart#L80) and [example's pubspec](https://github.com/Polidea/FlutterBleLib/blob/202c6fe48300be207f80567ca4bee5b6fbc83eb5/example/pubspec.yaml#L20). -### iOS +This library is using RxJava 2. Because of a difference in error handling between RxJava 1 and 2, +your/your user's application might encounter globally rethrown errors that were encountered after their consumer has finished its lifecycle. +[Read more here](https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling) +and [specifically about RxAndroidBle2 here](https://github.com/Polidea/RxAndroidBle/wiki/FAQ:-UndeliverableException) + +Recommended configuration is as follows. + +`app/build.gradle`: + +```groovy +... +dependencies { + ... + implementation 'io.reactivex.rxjava2:rxjava:2.2.17' + ... +} +``` + +`MainActivity.java`: -Go to `[project]/ios` directory and run `pod install`. +```dart +... +import io.reactivex.functions.Consumer; +import io.reactivex.plugins.RxJavaPlugins; + +public class MainActivity extends FlutterActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + ... + RxJavaPlugins.setErrorHandler(new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + Log.w("GlobalErrorHandler", throwable); + } + }); + } +} +``` +(feel free to replace consumer with a lambda) +### iOS Add [Privacy - Bluetooth Always Usage Description](https://developer.apple.com/documentation/bundleresources/information_property_list/nsbluetoothalwaysusagedescription) key to `[project]/ios/Runner/Info.plist` file. @@ -49,6 +86,8 @@ Add [Privacy - Bluetooth Always Usage Description](https://developer.apple.com/d ... ``` +Be sure to run `pod repo update` if you have issues with fetching Multiplatform BLE Adapter's pod. + ## Usage The library is organised around a few base entities, which are: diff --git a/android/build.gradle b/android/build.gradle index e50afd53..bceec84d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ group 'com.polidea.flutter_ble_lib' -version '2.3.1' +version '3.0.0-beta' buildscript { repositories { @@ -36,5 +36,5 @@ android { dependencies { implementation 'androidx.annotation:annotation:1.1.0' - implementation 'com.github.Polidea:MultiPlatformBleAdapter:0.1.7' + implementation 'com.github.Polidea:MultiPlatformBleAdapter:1.0.0-beta' } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 815cfd65..d2ea58ea 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -65,6 +65,7 @@ flutter { dependencies { testImplementation 'junit:junit:4.12' + implementation 'io.reactivex.rxjava2:rxjava:2.2.17' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } diff --git a/example/android/app/src/main/java/com/polidea/flutter_ble_lib_example/MainActivity.java b/example/android/app/src/main/java/com/polidea/flutter_ble_lib_example/MainActivity.java index f0cbbdc3..ace001bd 100644 --- a/example/android/app/src/main/java/com/polidea/flutter_ble_lib_example/MainActivity.java +++ b/example/android/app/src/main/java/com/polidea/flutter_ble_lib_example/MainActivity.java @@ -1,13 +1,17 @@ package com.polidea.flutter_ble_lib_example; import android.os.Bundle; +import android.util.Log; + import io.flutter.app.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant; +import io.reactivex.plugins.RxJavaPlugins; public class MainActivity extends FlutterActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GeneratedPluginRegistrant.registerWith(this); + RxJavaPlugins.setErrorHandler(throwable -> Log.w("GlobalErrorHandler", throwable)); } } diff --git a/ios/flutter_ble_lib.podspec b/ios/flutter_ble_lib.podspec index 138d92c7..dc40c7d4 100644 --- a/ios/flutter_ble_lib.podspec +++ b/ios/flutter_ble_lib.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_ble_lib' - s.version = '2.3.1' + s.version = '3.0.0-beta' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. @@ -16,7 +16,7 @@ A new flutter plugin project. s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' s.swift_versions = ['4.0', '4.2', '5.0'] - s.dependency 'MultiplatformBleAdapter', '~> 0.1.7' + s.dependency 'MultiplatformBleAdapter', '~> 1.0.0-beta' s.ios.deployment_target = '8.0' end diff --git a/pubspec.yaml b/pubspec.yaml index a9b4117f..21848d10 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_ble_lib description: FlutterBle Library is a flutter library that supports BLE operations. It uses MultiPlatformBleAdapter as a native backend.. -version: 2.3.1 +version: 3.0.0-beta homepage: https://github.com/Polidea/FlutterBleLib environment: