tp-rn-ble-advertiser
v5.2.0
Published
A React native BLE Advertiser
Downloads
1
Readme
tp-rn-ble-advertiser
Advertise given message using BLE
Installation
npm install tp-rn-ble-advertiser
Usage
Android
Add this to your AndroidManifest.xml inside application tag
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application ...>
...
<receiver
android:name="com.tulparyazilim.ble.RestartReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
...
</application>
iOS
Add this to Info.plist file for permission
<key>NSLocationWhenInUseUsageDescription</key>
<string>Need location permission to verify if you are scanning in correct location</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Need bluetooth permission for this app to function properly</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>bluetooth-peripheral</string>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>bluetooth-le</string>
</array>
React Native
import { Platform } from 'react-native';
import ReactNativeBleAdvertiser from 'tp-rn-ble-advertiser';
setTimeout(() => {
// start the service after setting data. Restart if the data is changed after starting
ReactNativeBleAdvertiser.startBroadcast('My Data');
setTimeout(() => {
// start the service after setting data. Restart if the data is changed after starting
ReactNativeBleAdvertiser.stopBroadcast();
}, 4000);
}, 4000);
Issues
Known issues
- Module currenly supports minimum android sdk of 22. Change your minSdkVersion in android/build.gradle to 22
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT