Omi SDK for React Native
A React Native SDK for connecting to and interacting with Omi devices via Bluetooth Low Energy (BLE).Features
- Scan for nearby Omi devices
- Connect to Omi devices
- Get device audio codec information
- Stream audio data from the device
- Monitor battery levels
- Handle connection state changes
- Real-time audio transcription using Deepgram
Development Setup
Prerequisites
- Node.js and npm installed
- Xcode (for iOS development)
- Android Studio (for Android development)
- CocoaPods (for iOS development)
Installation
- Clone the repository and navigate to the react-native directory:
- Install dependencies:
- Navigate to the example app directory and install its dependencies:
- For iOS development, install CocoaPods dependencies:
pod install
step is crucial and must not be skipped for iOS development. Without it, the app will fail to build with native module errors.
Running the Example App
iOS
- Make sure you’ve completed all installation steps above
- Open the example app’s workspace in Xcode:
- Select your target device (Note: Bluetooth functionality is not available in simulators)
- Build and run the project
Android
- Connect your Android device via USB
- Enable USB debugging on your device
- Run the app:
Installation in Your Project
Dependencies
This SDK relies on react-native-ble-plx for BLE communication.Platform-Specific Setup
For iOS, add the following to yourInfo.plist
:
AndroidManifest.xml
:
Usage
Basic Example
API Reference
OmiConnection
The main class for interacting with Omi devices.Methods
scanForDevices(onDeviceFound, timeoutMs = 10000)
Scans for nearby Omi devices.
onDeviceFound
: Callback function that receives an OmiDevice object when a device is foundtimeoutMs
: Scan timeout in milliseconds (default: 10000)- Returns: A function to stop scanning
connect(deviceId, onConnectionStateChanged)
Connects to an Omi device.
deviceId
: The ID of the device to connect toonConnectionStateChanged
: Optional callback for connection state changes- Returns: Promise that resolves to a boolean indicating success
disconnect()
Disconnects from the currently connected device.
- Returns: Promise that resolves when disconnected
isConnected()
Checks if connected to a device.
- Returns: Boolean indicating if connected
getAudioCodec()
Gets the audio codec used by the device.
- Returns: Promise that resolves with the audio codec (BleAudioCodec enum)
startAudioBytesListener(onAudioBytesReceived)
Starts listening for audio bytes from the device.
onAudioBytesReceived
: Callback function that receives audio bytes as a number array- Returns: Promise that resolves with a subscription that can be used to stop listening
stopAudioBytesListener(subscription)
Stops listening for audio bytes.
subscription
: The subscription returned by startAudioBytesListener- Returns: Promise that resolves when stopped
getBatteryLevel()
Gets the current battery level from the device.
- Returns: Promise that resolves with the battery level percentage (0-100)
Types
OmiDevice
DeviceConnectionState
BleAudioCodec
Troubleshooting
Common Issues
-
Build fails with native module errors on iOS
- Ensure you’ve run
pod install
in the ios directory - Try cleaning the build folder in Xcode (Product → Clean Build Folder)
- Make sure you’re opening the
.xcworkspace
file, not the.xcodeproj
file
- Ensure you’ve run
-
Device not found during scanning
- 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
- Note: Bluetooth scanning does not work in iOS simulators, use a physical device
-
Connection fails
- Try restarting the Omi device
- Ensure the device is not connected to another application
- Check battery level of the Omi device
-
Audio data not received
- Verify that the device supports the audio service
- Check that you’re properly handling the audio bytes in your callback
-
Transcription not working
- Ensure you have a valid Deepgram API key
- Check that the audio listener is started before enabling transcription
- Verify your internet connection is stable
-
Keyboard overlaps input fields
- The example app includes padding at the bottom of the ScrollView to ensure input fields remain visible when the keyboard is open