Skip to content

Latest commit

 

History

History
 
 

README.md

Overview

A React Native SDK for connecting to and interacting with Omi devices via Bluetooth Low Energy (BLE). Build cross-platform mobile apps for iOS and Android.

iOS and Android support Bluetooth Low Energy Stream and transcribe

Installation

In Your Project

npm install @omiai/omi-react-native
# or
yarn add @omiai/omi-react-native

This SDK relies on react-native-ble-plx for BLE communication:

npm install react-native-ble-plx
For iOS projects, you **must** run `pod install` after installing dependencies:
cd ios && pod install

Platform-Specific Setup

Add to your `Info.plist`:
```xml
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth to connect to Omi devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app uses Bluetooth to connect to Omi devices</string>
```
Add to your `AndroidManifest.xml`:
```xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- For Android 12+ -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
```

Quick Start

import { OmiConnection, DeviceConnectionState, BleAudioCodec } from '@omiai/omi-react-native';

// Create an instance of OmiConnection
const omiConnection = new OmiConnection();

// Scan for devices
const stopScan = omiConnection.scanForDevices((device) => {
  console.log('Found device:', device.name, device.id);
}, 10000); // Scan for 10 seconds

// Connect to a device
async function connectToDevice(deviceId) {
  const success = await omiConnection.connect(deviceId, (id, state) => {
    console.log(`Device ${id} connection state changed to: ${state}`);
  });

  if (success) {
    console.log('Connected successfully!');

    // Get the audio codec
    const codec = await omiConnection.getAudioCodec();
    console.log('Device audio codec:', codec);

    // Start listening for audio data
    const subscription = await omiConnection.startAudioBytesListener((bytes) => {
      console.log('Received audio bytes:', bytes.length);
    });

    // Get battery level
    const batteryLevel = await omiConnection.getBatteryLevel();
    console.log('Battery level:', batteryLevel);

    // Later, stop listening for audio
    await omiConnection.stopAudioBytesListener(subscription);

    // Disconnect when done
    await omiConnection.disconnect();
  }
}

Troubleshooting

- Ensure you've run `pod install` in the ios directory - Try cleaning the build folder: **Product → Clean Build Folder** - Make sure you're opening the `.xcworkspace` file, not `.xcodeproj` - Ensure Bluetooth is enabled on your device - Check that you have the necessary permissions - Make sure the Omi device is powered on and in range - Bluetooth scanning doesn't work in iOS simulators - use a physical device - Try restarting the Omi device - Ensure the device is not connected to another application - Check the battery level of the Omi device - Verify that the device supports the audio service - Check that you're properly handling the audio bytes in your callback - Ensure you have a valid Deepgram API key - Check that the audio listener is started before enabling transcription - Verify your internet connection is stable The example app includes padding at the bottom of the ScrollView to ensure input fields remain visible when the keyboard is open.

Related

Compare all available SDKs View source code and contribute