Skip to content

Commit

Permalink
ready for release 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukangi authored and Lukangi committed Jun 5, 2023
1 parent 5699a8d commit af4f4e8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 39 deletions.
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand All @@ -29,13 +29,14 @@ For target SDK version 29+ (Android 10, 11) is necessary to add manually ```ACCE
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
```
and if you want also background scanning:
and if you want also background scanning:
```
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
```
### 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
Expand Down Expand Up @@ -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 <br/> Location and Bluetooth (Settings -> Flutter Beacon)
* If example code don't works on device (beacons not appear), please make sure that you have enabled <br/> 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
}
Expand All @@ -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
});
Expand All @@ -124,18 +125,20 @@ _streamRanging.cancel();
final regions = <Region>[];
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
Expand Down
4 changes: 2 additions & 2 deletions beacon_scanner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.0.1
## 0.0.3

* TODO: Describe initial release.
* Initial release.
25 changes: 14 additions & 11 deletions beacon_scanner/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
});
Expand All @@ -126,15 +127,17 @@ final regions = <Region>[];
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
});
Expand Down
1 change: 1 addition & 0 deletions beacon_scanner/lib/src/beacon_scanner_service.dart
Original file line number Diff line number Diff line change
@@ -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._();
Expand Down
20 changes: 18 additions & 2 deletions beacon_scanner/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions beacon_scanner/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand Down

0 comments on commit af4f4e8

Please sign in to comment.