5.2.0 • Published 3 years ago

tp-rn-ble-advertiser v5.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

tp-rn-ble-advertiser

Build Status

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

5.2.0

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

4.0.0

3 years ago

3.0.5

3 years ago