パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.5.1

flutter_beacon

Android および iOS でスキャンしてビーコン(iBeacon)として送信するための Flutter プラグイン。

AndroidiOS
30日間ダウンロード
273
いいね数
88
Pub ポイント
140

パッケージをインストール

flutter pub add flutter_beacon

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Flutter Beacon は、Android および iOS デバイス上で Bluetooth Low Energy (BLE) ベーコンのスキャンと送信を可能にするクロスプラットフォームプラグインです。iBeacon機能をサポートしており、開発者が近隣のベーコンを検出したり、ベーコン信号をブロードキャストしたりできます。Flutterアプリにシームレスに統合され、探索モードと広告モードの両方に対して簡単なAPIを提供します。屋内ナビゲーション、資産トラッキング、場所認識サービスなどの近接ベースのアプリケーションに最適です。両プラットフォームのネイティブBLE機能と互換性があります。

用途

  • 屋内ナビゲーションシステム
  • 資産およびデバイスの追跡
  • プロキシミティマーケティング
  • 場所ベースのトリガー
  • スマートリテール体験

主な機能

  • iBeacon スキャンと送信
  • クロスプラットフォーム対応(Android および iOS)
  • シンプルな Flutter API
  • リアルタイムビーコン検出
  • 低消費電力

適している対象

  • 近接アプリを開発する開発者
  • インテリアポジショニングを必要とするアプリ
  • 小売およびホスピタリティソリューション
  • IoTデバイスの統合
  • イベントベースのモバイルアプリケーション

注意事項

  • 両プラットフォームでBluetooth権限が必要です
  • バックグラウンド操作は、OSの制限によって制限される可能性があります
  • 継続的なスキャン中はバッテリーの使用状況を監視する必要があります
  • 正確性は環境要因に依存します
  • iOSのバックグラウンドモードには追加の構成が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Flutter Beacon

Pub GitHub Build Coverage Status FOSSA Status codecov

Flutter plugin to work with iBeacons.

An hybrid iBeacon scanner and transmitter SDK for Flutter plugin. Supports Android API 18+ and iOS 8+.

Features:

  • Automatic permission management
  • Ranging iBeacons
  • Monitoring iBeacons
  • Transmit as iBeacon

Installation

Add to pubspec.yaml:

dependencies:
  flutter_beacon: latest
Setup specific for Android

For target SDK version 29+ (Android 10, 11) is necessary to add manually ACCESS_FINE_LOCATION

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

and if you want also background scanning:

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Setup specific for iOS

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
  2. Request the permission to the user when app is running (the plugin can handle this automatically)

The needed permissions in iOS is when in use.

For more details about what you can do with each permission, see:
https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services

Permission must be declared in ios/Runner/Info.plist:

<dict>
  <!-- When in use -->
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>
  <!-- Always -->
  <!-- for iOS 11 + -->
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>Reason why app needs location</string>
  <!-- for iOS 9/10 -->
  <key>NSLocationAlwaysUsageDescription</key>
  <string>Reason why app needs location</string>
  <!-- Bluetooth Privacy -->
  <!-- for iOS 13 + -->
  <key>NSBluetoothAlwaysUsageDescription</key>
  <string>Reason why app needs bluetooth</string>
</dict>

iOS Troubleshooting

  • Example code works properly only on physical device (bluetooth on simulator is disabled)
  • How to deploy flutter app on iOS device Instruction
  • 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.

  • The first subscription to the stream will start the ranging
Initializing Library
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;
} on PlatformException catch(e) {
  // library failed to initialize, check code and message
}
Ranging beacons
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'));
} 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) {
  // result contains a region and list of beacons found
  // list can be empty if no matching beacons were found in range
});

// to stop ranging beacons
_streamRanging.cancel();
Monitoring beacons
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'));
} 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) {
  // result contains a region, event type and event state
});

// to stop monitoring beacons
_streamMonitoring.cancel();

Under the hood

Author

Flutter Beacon plugin is developed by Eyro Labs. You can contact me at <maulana@cubeacon.com>.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。