beacon_broadcast 패키지는 안드로이드에서 AltBeacon 라이브러리와 iOS에서 CoreLocation을 사용하여 플러터 애플리케이션에서 장치를 블루투스 비컨으로 전환할 수 있게 해줍니다. 개발자가 사용자 정의 비컨 신호를 방송할 수 있어 실내 탐색, 위치 기반 알림 또는 자산 추적과 같은 근접 기반 상호작용에 유용합니다. 이 플러그인은 크로스플랫폼 호환성을 위해 설계되었으며 기존 비컨 생태계와 원활하게 통합됩니다. 포그라운드 및 백그라운드 비컨 전송을 모두 지원하여 장치 상태에 관계없이 일관된 신호 전송을 보장합니다.
사용 사례
실내 탐색 시스템
프록시미티 마케팅
창고 내 자산 추적
위치 기반 앱 트리거
스마트 홈 자동화
주요 기능
크로스 플랫폼 지원 (Android 및 iOS)
AltBeacon 및 CoreLocation 프레임워크 사용
사용자 정의 가능한 비콘 UUID, 메이저 및 마이너 값
백그라운드 비콘 방송
방송 시작/중지용 간단한 API
적합한 대상
근접 앱을 개발하는 개발자
실내 위치 추적을 필요로 하는 앱
소매 또는 기업 위치 서비스
사물인터넷 및 스마트 환경 프로젝트
고려 사항
모든 플랫폼에서 블루투스 권한이 필요합니다
지속적인 방송 중 배터리 사용량이 증가할 수 있습니다
iOS 백그라운드 모드는 올바른 구성이 필요합니다
비콘 감지 능력은 근처 장치의 스캔 기능에 따라 달라집니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Beacon Broadcast plugin for Flutter
A Flutter plugin for turning your device into a beacon.
Usage
To use this plugin, add beacon_broadcast as a dependency in your pubspec.yaml
file and import:
You can also listen for changes in beacon advertising state:
beaconBroadcast.getAdvertisingStateChange().listen((isAdvertising) {
// Now you know if beacon is advertising
});
Before advertising, you may want to check if your device supports transmitting
as a beacon. You may do it using
checkTransmissionSupported() method.
BeaconStatus transmissionSupportStatus = await beaconBroadcast.checkTransmissionSupported();
switch (transmissionSupportStatus) {
caseBeaconStatus.SUPPORTED:
// You're good to go, you can advertise as a beaconbreak;
caseBeaconStatus.NOT_SUPPORTED_MIN_SDK:
// Your Android system version is too low (min. is 21)break;
caseBeaconStatus.NOT_SUPPORTED_BLE:
// Your device doesn't support BLEbreak;
caseBeaconStatus.NOT_SUPPORTED_CANNOT_GET_ADVERTISER:
// Either your chipset or driver is incompatiblebreak;
}
If you want to stop advertising, just call stop():
By default beacons layout is set according to the manufacturer
(see section Beacon manufacturers). You can change
that layout to imitate transmitting as a different kind of beacon.
Note: For iOS layout is set to iBeacon and can't be changed.
If you have your beacon layout set accordingly, you're allowed to transmit
some extra data. Depending on the layout it's usually up to 2 bytes.
For AltBeacon it's 1 byte of additional data (source).
For iBeacon (iOS) there's no option to send extra data, as the iBeacon layout
doesn't support it.
Android beacon will advertise as the AltBeacon manufactured by RadiusNetwork.
You can change it with setLayout() and setManufacturerId() methods.
iOS
For iOS, beacon will advertise as an iBeacon (by Apple), it can't be changed.
Transmitting in the background
Android
Due to background execution limits introduced in Android 8
beacons transmission in the background is limited. Based on the
AltBeacon documentation
it's around 10 minutes, after that time transmission will stop.
Current version of plugin doesn't support Foreground Services to exceed this
limitation.
iOS
For iOS, application doesn't work in the background. According to the
CoreLocation
documentation:
Important
After advertising your app as a beacon, your app must continue running in the
foreground to broadcast the needed Bluetooth signals. If the user quits the
app, the system stops advertising the device as a peripheral over Bluetooth.In addition, since iOS 13, a privacy usage description is required to use Bluetooth. Otherwise, the app will experience a runtime crash.
To remedy this, add the following lines to your Info.plist
<key>NSBluetoothAlwaysUsageDescription</key><string>(Reason bluetooth is used)</string>
For deployment targets earlier than iOS 13, add these additional lines to your Info.plist
<key>NSBluetoothPeripheralUsageDescription</key><string>(Reason bluetooth is used)</string>