react-native-instantpay-bluetooth
TypeScript icon, indicating that this package has built-in type declarations

2.0.8 • Public • Published

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-bluetooth

iOS

Update your Info.plist with wanted permissions usage descriptions:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>YOUR TEXT</string>

Manual installation

Android

  1. 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 the getPackages() method
  1. 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')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-instantpay-bluetooth')
    

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-instantpay-bluetooth and add InstantpayBluetooth.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libInstantpayBluetooth.a to your project's Build PhasesLink Binary With Libraries
  4. 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

Package Sidebar

Install

npm i react-native-instantpay-bluetooth

Weekly Downloads

0

Version

2.0.8

License

MIT

Unpacked Size

75.5 kB

Total Files

24

Last publish

Collaborators

  • smithspeed