2.0.8 • Published 3 years ago
react-native-instantpay-bluetooth v2.0.8
react-native-instantpay-bluetooth
React Native module for checking Bluetooth state with event listener. Supports both iOS and Android.
TOC
Installation
npm install react-native-instantpay-bluetoothiOS
Update your Info.plist with wanted permissions usage descriptions:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>YOUR TEXT</string>Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.instantpaybluetooth.InstantpayBluetoothPackage;to the imports at the top of the file - Add
new InstantpayBluetoothPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':react-native-instantpay-bluetooth' project(':react-native-instantpay-bluetooth').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-instantpay-bluetooth/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':react-native-instantpay-bluetooth')
iOS
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-instantpay-bluetoothand addInstantpayBluetooth.xcodeproj - In XCode, in the project navigator, select your project. Add
libInstantpayBluetooth.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)
Usage
import RNBluetooth from 'react-native-instantpay-bluetooth';
// ...
let data = await RNBluetooth.getStatus();Note about getStatus Method
Possible options values :
| key | Description | type | required |
|---|---|---|---|
| requestToEnable | Request to Enable Bluetooth | boolean | Optional |
Event Listener Methods
//Add Listener
RNBluetooth.addEventListener("change", handleConnection);
//Remove Listener
RNBluetooth.removeEventListener("change", handleConnection);
handleConnection = (resp) => {
console.log('response:', resp);
}Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with Instantpay