beacons_plugin 플러그인은 Android 및 iOS용 Flutter 애플리케이션에서 iBeacon 스캔과 범위 측정을 간편하게 만듭니다. 개발자는 근처의 iBeacon을 감지하고 즉시, 가까움, 멀어짐과 같은 실시간 근접도 업데이트를 받을 수 있습니다. 이 플러그인은 네이티브 블루투스 기능과 원활하게 통합되어 복잡한 설정 없이 비콘 신호를 모니터링할 수 있는 간단한 API를 제공합니다. 위치 기반 서비스, 실내 탐색 및 컨텍스트 인식 앱에 적합합니다.
사용 사례
실내 탐색 시스템
거리 기반 알림
소매 고객 참여
자산 추적
컨텍스트 인식 모바일 경험
주요 기능
실시간 비콘 스캔
근접 감지(즉시, 가까움, 멀음)
크로스 플랫폼 지원 (Android 및 iOS)
Flutter와의 간단한 통합
백그라운드 모니터링 기능
적합한 대상
위치 인식 앱을 개발하는 개발자
소매 및 환대 앱
스마트 사무실 및 캠퍼스 솔루션
이벤트 기반 알림 시스템
실내 위치 기반 프로젝트
고려 사항
모든 플랫폼에서 블루투스 권한이 필요합니다
iBeacon 프로토콜에 제한됨
백그라운드 스캔은 배터리 수명에 영향을 줄 수 있습니다
iOS는 백그라운드 모드 구성이 필요합니다
정확도는 환경 요인에 따라 달라집니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
beacons_plugin
This plugin is developed to scan nearby iBeacons on both Android iOS. This library makes it easier to scan & range nearby BLE beacons and read their proximity values.
Android
For Android change min SDK version:
defaultConfig {
...
minSdkVersion 19
...
}
Change your Android Project's MainActivity class to following:
import com.umair.beacons_plugin.BeaconsPlugin
import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity(){
override fun onPause() {
super.onPause()
//Start Background service to scan BLE devices
BeaconsPlugin.startBackgroundService(this)
}
override fun onResume() {
super.onResume()
//Stop Background service, app is in foreground
BeaconsPlugin.stopBackgroundService(this)
}
}
That's it for Android.
iOS
In your AppDelegate.swift file change it to like this:
// if you need to monitor also major and minor use the original version and not this forkBeaconsPlugin.addRegion("myBeacon", "01022022-f88f-0000-00ae-9605fd9bb620")
.then((result) {
print(result);
});
//Send 'true' to run in background [OPTIONAL]awaitBeaconsPlugin.runInBackground(true);
//IMPORTANT: Start monitoring once scanner is setup & ready (only for Android)if (Platform.isAndroid) {
BeaconsPlugin.channel.setMethodCallHandler((call) async {
if (call.method == 'scannerReady') {
awaitBeaconsPlugin.startMonitoring();
}
});
} elseif (Platform.isIOS) {
awaitBeaconsPlugin.startMonitoring();
}
if (Platform.isAndroid) {
//Prominent disclosureawaitBeaconsPlugin.setDisclosureDialogMessage(
title: "Need Location Permission",
message: "This app collects location data to work with beacons.");
//Only in case, you want the dialog to be shown again. By Default, dialog will never be shown if permissions are granted.awaitBeaconsPlugin.clearDisclosureDialogShowFlag(false);
}
BeaconsPlugin.channel.setMethodCallHandler((call) async {
if (call.method == 'isPermissionDialogShown') {
//Do something here
}
});