From af4f4e84d9def4542aa4f085059562a0989c6d5f Mon Sep 17 00:00:00 2001 From: Lukangi Date: Mon, 5 Jun 2023 21:25:08 +0200 Subject: [PATCH] ready for release 0.0.3 --- README.md | 43 ++++++++++--------- beacon_scanner/CHANGELOG.md | 4 +- beacon_scanner/README.md | 25 ++++++----- .../lib/src/beacon_scanner_service.dart | 1 + beacon_scanner/pubspec.lock | 20 ++++++++- beacon_scanner/pubspec.yaml | 8 ++-- 6 files changed, 62 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index d1458bd..e3feb7f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # beacon_scanner -This plugin is based on flutter_beacon(https://pub.dev/packages/flutter_beacon) by Eyro Labs. +This plugin is based on [flutter_beacon](https://pub.dev/packages/flutter_beacon) by Eyro Labs. This package can be combined with androids foreground services. It uses Android AltBeacon and iOS CoreLocation under the hood. @@ -9,7 +9,7 @@ An hybrid iBeacon scanner SDK for Flutter plugin. Supports Android API 18+ and i Features: * Automatic permission management -* Ranging iBeacons +* Ranging iBeacons * Monitoring iBeacons ## Installation @@ -29,13 +29,14 @@ For target SDK version 29+ (Android 10, 11) is necessary to add manually ```ACCE ``` -and if you want also background scanning: +and if you want also background scanning: ``` ``` ### Setup specific for iOS +Works only for 13+. In order to use beacons related features, apps are required to ask the location permission. It's a two step process: 1. Declare the permission the app requires in configuration files @@ -71,23 +72,22 @@ Permission must be declared in `ios/Runner/Info.plist`: * Example code works properly only on **physical device** (bluetooth on simulator is disabled) * How to deploy flutter app on iOS device [Instruction](https://flutter.dev/docs/get-started/install/macos) -* If example code don't works on device (beacons not appear), please make sure that you have enabled
Location and Bluetooth (Settings -> Flutter Beacon) +* If example code don't works on device (beacons not appear), please make sure that you have enabled
Location and Bluetooth (Settings -> Flutter Beacon) ## How-to -Ranging APIs are designed as reactive streams. +Ranging APIs are designed as reactive streams. * The first subscription to the stream will start the ranging ### Initializing Library ```dart +final BeaconScanner beaconScanner = BeaconScanner.instance; + try { - // if you want to manage manual checking about the required permissions - await flutterBeacon.initializeScanning; - - // or if you want to include automatic checking permission - await flutterBeacon.initializeAndCheckScanning; + // false - if you want to manage manual checking about the required permissions + await beaconScanner.initialize(true); } on PlatformException catch(e) { // library failed to initialize, check code and message } @@ -102,14 +102,15 @@ if (Platform.isIOS) { // iOS platform, at least set identifier and proximityUUID for region scanning regions.add(Region( identifier: 'Apple Airlocate', - proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0')); + beaconId: IBeaconId(proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'), + )); } else { // android platform, it can ranging out of beacon that filter all of Proximity UUID regions.add(Region(identifier: 'com.beacon')); } // to start ranging beacons -_streamRanging = flutterBeacon.ranging(regions).listen((RangingResult result) { +_streamRanging = beaconScanner.ranging(regions).listen((ScanResult result) { // result contains a region and list of beacons found // list can be empty if no matching beacons were found in range }); @@ -124,18 +125,20 @@ _streamRanging.cancel(); final regions = []; if (Platform.isIOS) { - // iOS platform, at least set identifier and proximityUUID for region scanning - regions.add(Region( - identifier: 'Apple Airlocate', - proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0')); +// iOS platform, at least set identifier and proximityUUID for region scanning +regions.add(Region( +identifier: 'Apple Airlocate', +beaconId: IBeaconId(proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'), +)); } else { - // Android platform, it can ranging out of beacon that filter all of Proximity UUID - regions.add(Region(identifier: 'com.beacon')); +// Android platform, it can ranging out of beacon that filter all of Proximity UUID +regions.add(Region(identifier: 'com.beacon')); } // to start monitoring beacons -_streamMonitoring = flutterBeacon.monitoring(regions).listen((MonitoringResult result) { - // result contains a region, event type and event state +// even works when app is closed on iOS +_streamMonitoring = beaconScanner.monitoring(regions).listen((MonitoringResult result) { +// result contains a region, event type and event state }); // to stop monitoring beacons diff --git a/beacon_scanner/CHANGELOG.md b/beacon_scanner/CHANGELOG.md index 41cc7d8..e26e55f 100644 --- a/beacon_scanner/CHANGELOG.md +++ b/beacon_scanner/CHANGELOG.md @@ -1,3 +1,3 @@ -## 0.0.1 +## 0.0.3 -* TODO: Describe initial release. +* Initial release. diff --git a/beacon_scanner/README.md b/beacon_scanner/README.md index c5ec7e0..5dfebbb 100644 --- a/beacon_scanner/README.md +++ b/beacon_scanner/README.md @@ -1,6 +1,6 @@ # beacon_scanner -This plugin is based on flutter_beacon(https://pub.dev/packages/flutter_beacon) by Eyro Labs. +This plugin is based on [flutter_beacon](https://pub.dev/packages/flutter_beacon) by Eyro Labs. This package can be combined with androids foreground services. It uses Android AltBeacon and iOS CoreLocation under the hood. @@ -36,6 +36,7 @@ and if you want also background scanning: ### Setup specific for iOS +Works only for 13+. In order to use beacons related features, apps are required to ask the location permission. It's a two step process: 1. Declare the permission the app requires in configuration files @@ -82,12 +83,11 @@ Ranging APIs are designed as reactive streams. ### Initializing Library ```dart +final BeaconScanner beaconScanner = BeaconScanner.instance; + try { - // if you want to manage manual checking about the required permissions - await flutterBeacon.initializeScanning; - - // or if you want to include automatic checking permission - await flutterBeacon.initializeAndCheckScanning; + // false - if you want to manage manual checking about the required permissions + await beaconScanner.initialize(true); } on PlatformException catch(e) { // library failed to initialize, check code and message } @@ -102,14 +102,15 @@ if (Platform.isIOS) { // iOS platform, at least set identifier and proximityUUID for region scanning regions.add(Region( identifier: 'Apple Airlocate', - proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0')); + beaconId: IBeaconId(proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'), + )); } else { // android platform, it can ranging out of beacon that filter all of Proximity UUID regions.add(Region(identifier: 'com.beacon')); } // to start ranging beacons -_streamRanging = flutterBeacon.ranging(regions).listen((RangingResult result) { +_streamRanging = beaconScanner.ranging(regions).listen((ScanResult result) { // result contains a region and list of beacons found // list can be empty if no matching beacons were found in range }); @@ -126,15 +127,17 @@ final regions = []; if (Platform.isIOS) { // iOS platform, at least set identifier and proximityUUID for region scanning regions.add(Region( - identifier: 'Apple Airlocate', - proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0')); + identifier: 'Apple Airlocate', + beaconId: IBeaconId(proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'), + )); } else { // Android platform, it can ranging out of beacon that filter all of Proximity UUID regions.add(Region(identifier: 'com.beacon')); } // to start monitoring beacons -_streamMonitoring = flutterBeacon.monitoring(regions).listen((MonitoringResult result) { +// even works when app is closed on iOS +_streamMonitoring = beaconScanner.monitoring(regions).listen((MonitoringResult result) { // result contains a region, event type and event state }); diff --git a/beacon_scanner/lib/src/beacon_scanner_service.dart b/beacon_scanner/lib/src/beacon_scanner_service.dart index ef32c32..57b5845 100644 --- a/beacon_scanner/lib/src/beacon_scanner_service.dart +++ b/beacon_scanner/lib/src/beacon_scanner_service.dart @@ -1,5 +1,6 @@ import 'package:beacon_scanner_platform_interface/beacon_scanner_platform_interface.dart'; +/// Service for interacting with bluetooth beacon which uses iBeacon protocol class BeaconScanner { /// Instance of Beacon-Service static final BeaconScanner instance = BeaconScanner._(); diff --git a/beacon_scanner/pubspec.lock b/beacon_scanner/pubspec.lock index 941bdf2..e6ebd87 100644 --- a/beacon_scanner/pubspec.lock +++ b/beacon_scanner/pubspec.lock @@ -9,14 +9,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.10.0" + beacon_scanner_android: + dependency: "direct main" + description: + name: beacon_scanner_android + sha256: "29af0f09b30c7622b8b6f69baa9e2af585e0a02c348d52bab5c8630046fc2c56" + url: "https://pub.dev" + source: hosted + version: "0.0.3" + beacon_scanner_ios: + dependency: "direct main" + description: + name: beacon_scanner_ios + sha256: "518d04c9bc8f04a07c84a7a2506d3d24eaf30edb1109e234c9ad8f37ab550348" + url: "https://pub.dev" + source: hosted + version: "0.0.3+1" beacon_scanner_platform_interface: dependency: "direct main" description: name: beacon_scanner_platform_interface - sha256: ae93534599a6b900d587a4e5bdf698da9f347cb24dc7c779bfdb5e7f1a0fb4d1 + sha256: bf90a70f73ad58f44567ee58d84afdf0e733e1743519469efc13786b08007c70 url: "https://pub.dev" source: hosted - version: "0.0.2" + version: "0.0.3" boolean_selector: dependency: transitive description: diff --git a/beacon_scanner/pubspec.yaml b/beacon_scanner/pubspec.yaml index 434d693..b3a7801 100644 --- a/beacon_scanner/pubspec.yaml +++ b/beacon_scanner/pubspec.yaml @@ -1,6 +1,6 @@ name: beacon_scanner description: A Flutter plugin for Scanning iBeacon. -version: 0.0.1 +version: 0.0.3 environment: sdk: ">=2.18.0 <4.0.0" @@ -17,9 +17,9 @@ flutter: dependencies: flutter: sdk: flutter - beacon_scanner_android: ^0.0.1 - beacon_scanner_ios: ^0.0.1 - beacon_scanner_platform_interface: ^0.0.2 + beacon_scanner_android: ^0.0.3 + beacon_scanner_ios: ^0.0.3+1 + beacon_scanner_platform_interface: ^0.0.3 dev_dependencies: flutter_test: