Getting the library

npm install react-native-telink-ble

or using yarn:

yarn add react-native-telink-ble

Android configuration

Add Kotlin support

Add Kotlin support to your project follow this guide:

Add TelinkBleMeshLib to your Gradle settings

Add this to settings.gradle:

project(":TelinkBleMeshLib").projectDir = new File("../node_modules/react-native-telink-ble/android/TelinkBleMeshLib")

Add this to app/build.gradle:

dependencies {
  // ...

  implemetation project(":TelinkBleMeshLib")

Extends TelinkBleApplication

Replace your or MainApplication.kt to extends the TelinkBleApplication class:

// ...
import com.react.telink.ble.TelinkBleApplication

class MainApplication : TelinkBleApplication(), ReactApplication {
    // ...

Extends TelinkBleActivity

Replace your or MainActivity.kt to extends the TelinkBleActivity class:

// ...
import com.react.telink.ble.TelinkBleActivity

class MainActivity : TelinkBleActivity() {
    // ...

Permission declaration

Bluetooth permissions are already declared in the library

iOS configuration

Adding Pod dependencies

  pod "TelinkSigMeshLib",        :path => "../node_modules/react-native-telink-ble"
  pod "react-native-telink-ble", :path => "../node_modules/react-native-telink-ble"

Adding Swift support

Simply create a new Swift source file inside your iOS project with bridging header enabled.

Configure MeshSDK

Add import statements to your file:

#import <react-native-telink-ble/TelinkBle.h>
#import <react-native-telink-ble/TelinkBle+MeshSDK.h>

and inside didFinishLaunchingWithOptions method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  // ...
  [self.window makeKeyAndVisible];
  [TelinkBle startMeshSDK]; // <- add this
  return YES;

Permission declaration

Add the following privacy statements to Info.plist:

<string>App needs Bluetooth permission to scan, connect and control BLE devices</string>
<string>App needs Bluetooth permission to scan, connect and control BLE devices</string>