@revrag-ai/embed-react-native 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +253 -274
  3. package/android/CMakeLists.txt +15 -0
  4. package/android/build.gradle +77 -25
  5. package/android/cpp-adapter.cpp +8 -0
  6. package/android/generated/java/com/revragai/embedreactnative/NativeEmbedReactNativeSpec.java +37 -0
  7. package/android/generated/jni/CMakeLists.txt +49 -0
  8. package/android/generated/jni/RNEmbedReactNativeSpec-generated.cpp +32 -0
  9. package/android/generated/jni/RNEmbedReactNativeSpec.h +31 -0
  10. package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
  11. package/android/generated/jni/react/renderer/components/RNEmbedReactNativeSpec/RNEmbedReactNativeSpecJSI.h +67 -0
  12. package/android/gradle.properties +5 -5
  13. package/cpp/revrag-ai-embed-react-native.cpp +7 -0
  14. package/cpp/revrag-ai-embed-react-native.h +8 -0
  15. package/ios/EmbedReactNative.h +9 -0
  16. package/ios/{Onwid.mm → EmbedReactNative.mm} +4 -4
  17. package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec-generated.mm +29 -0
  18. package/ios/generated/RNEmbedReactNativeSpec/RNEmbedReactNativeSpec.h +50 -0
  19. package/ios/generated/RNEmbedReactNativeSpecJSI-generated.cpp +28 -0
  20. package/ios/generated/RNEmbedReactNativeSpecJSI.h +67 -0
  21. package/lib/commonjs/NativeEmbedReactNative.js +9 -0
  22. package/{dist/commonjs/onwidApi → lib/commonjs/api}/api.js +86 -15
  23. package/lib/commonjs/api/types/embed.api.types.js +2 -0
  24. package/{dist/module/component/audiowave.js → lib/commonjs/components/Embed/EmbedAudioWave.js} +21 -17
  25. package/{dist/module/component/OnwidButton.js → lib/commonjs/components/Embed/EmbedButton.js} +65 -61
  26. package/{dist/module/component/voice.js → lib/commonjs/components/Embed/EmbedVoice.js} +18 -14
  27. package/{dist/commonjs/style/onwidButton.style.js → lib/commonjs/components/styles/EmbedButton.style.js} +14 -9
  28. package/{dist/module/Event/onwid.js → lib/commonjs/events/embed.event.js} +14 -10
  29. package/{dist → lib}/commonjs/hooks/initialize.js +22 -22
  30. package/{dist/commonjs/hooks/initializelivekit.js → lib/commonjs/hooks/initialize.livekit.js} +8 -5
  31. package/lib/commonjs/hooks/types/voiceAgent.types.js +6 -0
  32. package/{dist/module/hooks/voiceAgent.js → lib/commonjs/hooks/voiceagent.js} +36 -31
  33. package/lib/commonjs/index.js +34 -0
  34. package/{dist/module/index.d.js → lib/commonjs/index.types.js} +7 -7
  35. package/lib/commonjs/store/store.key.js +46 -0
  36. package/{dist/module/utils/reanimatedHelpers.js → lib/commonjs/utils/reanimated.helper.js} +23 -17
  37. package/lib/module/NativeEmbedReactNative.js +5 -0
  38. package/{dist/module/onwidApi → lib/module/api}/api.js +69 -6
  39. package/lib/module/api/types/embed.api.types.js +2 -0
  40. package/{dist/commonjs/component/audiowave.js → lib/module/components/Embed/EmbedAudioWave.js} +2 -3
  41. package/{dist/commonjs/component/OnwidButton.js → lib/module/components/Embed/EmbedButton.js} +10 -11
  42. package/{dist/commonjs/component/voice.js → lib/module/components/Embed/EmbedVoice.js} +1 -1
  43. package/{dist/module/style/onwidButton.style.js → lib/module/components/styles/EmbedButton.style.js} +3 -3
  44. package/{dist/commonjs/Event/onwid.js → lib/module/events/embed.event.js} +6 -6
  45. package/{dist → lib}/module/hooks/initialize.js +7 -13
  46. package/{dist/module/hooks/initializelivekit.js → lib/module/hooks/initialize.livekit.js} +1 -1
  47. package/{dist/commonjs/hooks/voiceAgent.js → lib/module/hooks/voiceagent.js} +4 -4
  48. package/lib/module/index.js +7 -0
  49. package/{dist/commonjs/index.d.js → lib/module/index.types.js} +2 -1
  50. package/{dist/commonjs/utils/reanimatedHelpers.js → lib/module/utils/reanimated.helper.js} +14 -14
  51. package/lib/typescript/module/package.json +1 -0
  52. package/package.json +71 -35
  53. package/react-native.config.js +8 -14
  54. package/revrag-ai-embed-react-native.podspec +41 -0
  55. package/Onwid.podspec +0 -20
  56. package/dist/commonjs/NativeOnwid.js +0 -5
  57. package/dist/commonjs/button.json +0 -1
  58. package/dist/commonjs/index.js +0 -34
  59. package/dist/commonjs/onwidApi/api.types.js +0 -2
  60. package/dist/commonjs/utils/utils.js +0 -2
  61. package/dist/module/NativeOnwid.js +0 -5
  62. package/dist/module/button.json +0 -1
  63. package/dist/module/hooks/voiceAgent.types.js +0 -4
  64. package/dist/module/index.js +0 -34
  65. package/dist/module/onwidApi/api.types.js +0 -2
  66. package/dist/module/store.key.js +0 -38
  67. package/dist/module/utils/utils.js +0 -2
  68. package/dist/typescript/Event/onwid.d.ts +0 -14
  69. package/dist/typescript/NativeOnwid.d.ts +0 -7
  70. package/dist/typescript/component/OnwidButton.d.ts +0 -29
  71. package/dist/typescript/component/audiowave.d.ts +0 -7
  72. package/dist/typescript/component/voice.d.ts +0 -16
  73. package/dist/typescript/hooks/initialize.d.ts +0 -3
  74. package/dist/typescript/hooks/initialize.types.d.ts +0 -6
  75. package/dist/typescript/hooks/initializelivekit.d.ts +0 -4
  76. package/dist/typescript/hooks/voiceAgent.d.ts +0 -3
  77. package/dist/typescript/hooks/voiceAgent.types.d.ts +0 -17
  78. package/dist/typescript/index.d.ts +0 -27
  79. package/dist/typescript/onwidApi/api.d.ts +0 -54
  80. package/dist/typescript/onwidApi/api.types.d.ts +0 -22
  81. package/dist/typescript/store.key.d.ts +0 -4
  82. package/dist/typescript/style/onwidButton.style.d.ts +0 -99
  83. package/dist/typescript/utils/reanimatedHelpers.d.ts +0 -30
  84. package/dist/typescript/utils/utils.d.ts +0 -1
  85. package/ios/Onwid.h +0 -5
  86. package/scripts/verify-setup.js +0 -90
  87. /package/{dist/commonjs/hooks → lib/commonjs/hooks/types}/initialize.types.js +0 -0
  88. /package/{dist/module/hooks → lib/module/hooks/types}/initialize.types.js +0 -0
  89. /package/{dist/commonjs/hooks → lib/module/hooks/types}/voiceAgent.types.js +0 -0
  90. /package/{dist/commonjs → lib/module/store}/store.key.js +0 -0
  91. /package/{dist → lib/typescript}/commonjs/package.json +0 -0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 revragai
3
+ Copyright (c) 2025 RevragAi
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
6
6
  in the Software without restriction, including without limitation the rights
package/README.md CHANGED
@@ -1,103 +1,39 @@
1
1
  # @revrag-ai/embed-react-native
2
2
 
3
- [![npm version](https://badge.fury.io/js/%40revrag-ai%2Fembed-react-native.svg)](https://badge.fury.io/js/%40revrag-ai%2Fembed-react-native)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
-
6
- A powerful Voice Agent SDK for React Native that enables AI-powered voice communication with real-time speech processing. Built with LiveKit for seamless voice interactions.
3
+ A powerful React Native library for integrating AI-powered voice agents into your mobile applications. This SDK provides real-time voice communication capabilities with intelligent speech processing, perfect for building conversational AI experiences.
7
4
 
8
5
  ## 🚀 Features
9
6
 
10
- - **Real-time Voice Communication**: High-quality voice chat powered by LiveKit
11
- - **AI Voice Agent Integration**: Seamless integration with AI voice assistants
12
- - **Cross-platform Support**: Works on both iOS and Android
7
+ - **AI Voice Agent Integration**: Seamlessly integrate intelligent voice agents into your React Native app
8
+ - **Real-time Voice Communication**: High-quality, low-latency voice chat powered by LiveKit
9
+ - **Voice Activity Detection**: Automatic speech detection and processing
10
+ - **Customizable UI Components**: Pre-built, customizable voice interface components
11
+ - **Cross-platform**: Works on both iOS and Android
13
12
  - **TypeScript Support**: Full TypeScript definitions included
14
- - **Event-driven Architecture**: Flexible event system for custom integrations
15
- - **Secure API Communication**: Protected API calls with automatic initialization
16
- - **Easy Integration**: Simple hooks and components for quick setup
13
+ - **Event System**: Comprehensive event handling for voice interactions
14
+ - **Audio Visualization**: Built-in waveform visualization for voice activity
17
15
 
18
16
  ## 📦 Installation
19
17
 
20
- ```bash
18
+ ```sh
21
19
  npm install @revrag-ai/embed-react-native
22
- # or
23
- yarn add @revrag-ai/embed-react-native
24
20
  ```
25
21
 
26
22
  ### Peer Dependencies
27
23
 
28
- Make sure you have the following peer dependencies installed:
24
+ Make sure to install the required peer dependencies:
29
25
 
30
- ```bash
26
+ ```sh
31
27
  npm install @livekit/react-native @livekit/react-native-webrtc @react-native-async-storage/async-storage lottie-react-native react-native-gesture-handler react-native-linear-gradient react-native-reanimated react-native-safe-area-context
32
28
  ```
33
29
 
34
- ### Important: React Native Reanimated Setup
35
-
36
- **This library requires `react-native-reanimated` to be properly installed and configured.** If you encounter errors like "Cannot read property 'makeMutable' of undefined", follow these steps:
37
-
38
- 1. **Install react-native-reanimated:**
39
- ```bash
40
- npm install react-native-reanimated
41
- # or
42
- yarn add react-native-reanimated
43
- ```
44
-
45
- 2. **Add Reanimated's babel plugin to your `babel.config.js`:**
46
- ```javascript
47
- module.exports = {
48
- presets: ['module:@react-native/babel-preset'],
49
- plugins: [
50
- 'react-native-reanimated/plugin',
51
- ],
52
- };
53
- ```
54
-
55
- 3. **For iOS:** Run `cd ios && pod install`
56
-
57
- 4. **For Android:** Add the following to `android/app/src/main/java/.../MainApplication.java`:
58
- ```java
59
- import com.swmansion.reanimated.ReanimatedPackage;
60
-
61
- @Override
62
- protected List<ReactPackage> getPackages() {
63
- return Arrays.<ReactPackage>asList(
64
- new MainReactPackage(),
65
- new ReanimatedPackage() // Add this line
66
- );
67
- }
68
- ```
69
-
70
- 5. **Clean and rebuild your project:**
71
- ```bash
72
- # For React Native CLI
73
- npx react-native run-android
74
- npx react-native run-ios
75
-
76
- # For Expo (if using)
77
- expo run:android
78
- expo run:ios
79
- ```
80
-
81
- For more detailed instructions, visit: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started
82
-
83
- ### Setup Verification
84
-
85
- After installation, you can verify your setup by running:
86
-
87
- ```bash
88
- npx @revrag-ai/embed-react-native verify-setup
89
- ```
90
-
91
- This will check if all dependencies are properly installed and configured.
92
-
93
- ## 🛠️ Setup
94
-
95
30
  ### iOS Setup
96
31
 
97
- Add the following to your `ios/Podfile`:
32
+ Add the following to your `ios/YourApp/Info.plist`:
98
33
 
99
- ```ruby
100
- pod 'RNFS', :path => '../node_modules/react-native-fs'
34
+ ```xml
35
+ <key>NSMicrophoneUsageDescription</key>
36
+ <string>This app needs microphone access for voice communication</string>
101
37
  ```
102
38
 
103
39
  ### Android Setup
@@ -110,293 +46,336 @@ Add the following permissions to your `android/app/src/main/AndroidManifest.xml`
110
46
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
111
47
  ```
112
48
 
113
- ## 🔧 Troubleshooting
49
+ ## 🎯 Quick Start
50
+
51
+ ### 1. Initialize the SDK
114
52
 
115
- ### "Cannot read property 'makeMutable' of undefined"
53
+ Wrap your app with the initialization hook:
116
54
 
117
- This error occurs when `react-native-reanimated` is not properly installed or configured. Follow these steps:
55
+ ```tsx
56
+ import React from 'react';
57
+ import { useInitialize } from '@revrag-ai/embed-react-native';
118
58
 
119
- 1. **Ensure react-native-reanimated is installed:**
120
- ```bash
121
- npm list react-native-reanimated
122
- ```
59
+ export default function App() {
60
+ useInitialize({
61
+ apiKey: 'your-api-key-here',
62
+ embedUrl: 'https://your-voice-agent-server.com',
63
+ });
123
64
 
124
- 2. **Check your babel.config.js includes the reanimated plugin:**
125
- ```javascript
126
- module.exports = {
127
- presets: ['module:@react-native/babel-preset'],
128
- plugins: [
129
- 'react-native-reanimated/plugin', // <- This line is crucial
130
- ],
131
- };
132
- ```
65
+ return <YourAppContent />;
66
+ }
67
+ ```
133
68
 
134
- 3. **Clear Metro cache and rebuild:**
135
- ```bash
136
- npx react-native start --reset-cache
137
- npx react-native run-android # or run-ios
138
- ```
69
+ ### 2. Add the Voice Button
139
70
 
140
- 4. **For iOS, ensure pods are installed:**
141
- ```bash
142
- cd ios && pod install && cd ..
143
- ```
71
+ Add the voice interface component to your screen:
144
72
 
145
- ### Component Not Rendering
73
+ ```tsx
74
+ import React from 'react';
75
+ import { View } from 'react-native';
76
+ import { EmbedButton } from '@revrag-ai/embed-react-native';
146
77
 
147
- If the OnwidButton component doesn't appear or crashes:
78
+ export default function HomeScreen() {
79
+ return (
80
+ <View style={{ flex: 1 }}>
81
+ {/* Your app content */}
82
+
83
+ {/* Voice agent button - floats over content */}
84
+ <EmbedButton />
85
+ </View>
86
+ );
87
+ }
88
+ ```
148
89
 
149
- - Ensure all peer dependencies are installed
150
- - Check that your app has proper permissions for microphone access
151
- - Verify your API key and server URL are correct
90
+ ### 3. Handle Voice Events (Optional)
152
91
 
153
- ### Voice Connection Issues
92
+ Listen to voice agent events for custom handling:
154
93
 
155
- If voice connection fails:
94
+ ```tsx
95
+ import React, { useEffect } from 'react';
96
+ import { Embed, EmbedEventKeys } from '@revrag-ai/embed-react-native';
97
+
98
+ export default function VoiceEnabledScreen() {
99
+ useEffect(() => {
100
+ // Listen for user data events
101
+ Embed.on(EmbedEventKeys.USER_DATA, (data) => {
102
+ console.log('User data received:', data);
103
+ });
104
+
105
+ // Listen for screen state events
106
+ Embed.on(EmbedEventKeys.SCREEN_STATE, (state) => {
107
+ console.log('Screen state changed:', state);
108
+ });
109
+ }, []);
156
110
 
157
- - Check your network connection
158
- - Verify your API key is valid
159
- - Ensure microphone permissions are granted
160
- - Check the console for detailed error messages
111
+ return (
112
+ // Your component JSX
113
+ );
114
+ }
115
+ ```
161
116
 
162
- ## 🎯 Quick Start
117
+ ## 📖 API Reference
163
118
 
164
- ### 1. Initialize the SDK
119
+ ### `useInitialize(props: UseInitializeProps)`
120
+
121
+ Initializes the voice agent SDK with your configuration.
122
+
123
+ #### Parameters
124
+
125
+ | Parameter | Type | Required | Description |
126
+ |-----------|------|----------|-------------|
127
+ | `apiKey` | `string` | ✅ | Your unique API key from RevRag AI |
128
+ | `embedUrl` | `string` | ✅ | The voice agent server URL |
129
+
130
+ #### Example
165
131
 
166
132
  ```tsx
167
- import { useInitialize } from '@revrag-ai/embed-react-native';
133
+ useInitialize({
134
+ apiKey: 'key_abc123',
135
+ embedUrl: 'https://api.revrag.ai',
136
+ });
137
+ ```
168
138
 
169
- function App() {
170
- useInitialize({
171
- apiKey: 'your-api-key',
172
- onwidUrl: 'https://your-onwid-server.com',
173
- metadata: {
174
- config: {
175
- // Your configuration
176
- }
177
- }
178
- });
139
+ ### `<EmbedButton />`
179
140
 
180
- return (
181
- // Your app content
182
- );
183
- }
141
+ A floating action button that provides the voice interface.
142
+
143
+ #### Features
144
+
145
+ - **Draggable**: Users can drag the button around the screen
146
+ - **Expandable**: Expands to show voice controls when active
147
+ - **Auto-opening**: Automatically prompts users after 15 seconds
148
+ - **Visual Feedback**: Shows connection status and audio visualization
149
+ - **Customizable**: Supports custom styling
150
+
151
+ #### Example
152
+
153
+ ```tsx
154
+ import { EmbedButton } from '@revrag-ai/embed-react-native';
155
+
156
+ // Basic usage
157
+ <EmbedButton />
158
+
159
+ // The button automatically handles:
160
+ // - Voice agent connection
161
+ // - Microphone permissions
162
+ // - Audio recording and playback
163
+ // - Call management
184
164
  ```
185
165
 
186
- ### 2. Use the Voice Agent
166
+ ### `useVoiceAgent()`
167
+
168
+ Hook for advanced voice agent control and state management.
169
+
170
+ #### Returns
171
+
172
+ | Property | Type | Description |
173
+ |----------|------|-------------|
174
+ | `initializeVoiceAgent` | `() => Promise<void>` | Manually initialize voice connection |
175
+ | `isLoading` | `boolean` | Connection loading state |
176
+ | `error` | `string \| null` | Current error message |
177
+ | `tokenDetails` | `TokenDetails` | Authentication token information |
178
+ | `endCall` | `() => Promise<void>` | End the current voice session |
179
+ | `room` | `Room` | LiveKit room instance |
180
+ | `roomRef` | `RefObject<Room>` | Room reference for advanced usage |
181
+ | `isMicMuted` | `boolean` | Microphone mute state |
182
+ | `muteMic` | `() => void` | Mute the microphone |
183
+ | `unmuteMic` | `() => void` | Unmute the microphone |
184
+ | `connectionState` | `ConnectionState` | Current connection status |
185
+ | `cleanup` | `() => void` | Clean up resources |
186
+
187
+ #### Example
187
188
 
188
189
  ```tsx
189
190
  import { useVoiceAgent } from '@revrag-ai/embed-react-native';
190
191
 
191
- function VoiceComponent() {
192
+ function CustomVoiceInterface() {
192
193
  const {
193
194
  initializeVoiceAgent,
194
195
  endCall,
196
+ isMicMuted,
195
197
  muteMic,
196
198
  unmuteMic,
197
- isMicMuted,
198
199
  connectionState,
199
- isLoading,
200
- error
200
+ isLoading
201
201
  } = useVoiceAgent();
202
202
 
203
- const startVoiceCall = async () => {
203
+ const handleStartCall = async () => {
204
204
  try {
205
205
  await initializeVoiceAgent();
206
206
  } catch (error) {
207
- console.error('Failed to start voice call:', error);
207
+ console.error('Failed to start call:', error);
208
208
  }
209
209
  };
210
210
 
211
211
  return (
212
212
  <View>
213
- <Button title="Start Voice Call" onPress={startVoiceCall} />
214
- <Button title="End Call" onPress={endCall} />
215
213
  <Button
216
- title={isMicMuted ? "Unmute" : "Mute"}
217
- onPress={isMicMuted ? unmuteMic : muteMic}
214
+ title={connectionState === 'connected' ? 'End Call' : 'Start Call'}
215
+ onPress={connectionState === 'connected' ? endCall : handleStartCall}
216
+ disabled={isLoading}
218
217
  />
218
+
219
+ {connectionState === 'connected' && (
220
+ <Button
221
+ title={isMicMuted ? 'Unmute' : 'Mute'}
222
+ onPress={isMicMuted ? unmuteMic : muteMic}
223
+ />
224
+ )}
225
+
219
226
  <Text>Status: {connectionState}</Text>
220
- {isLoading && <Text>Loading...</Text>}
221
- {error && <Text>Error: {error}</Text>}
222
227
  </View>
223
228
  );
224
229
  }
225
230
  ```
226
231
 
227
- ### 3. Handle Events
232
+ ### Event System
228
233
 
229
- ```tsx
230
- import { onwid, EventKeys } from '@revrag-ai/embed-react-native';
231
-
232
- // Send user data
233
- await onwid.Event(EventKeys.USER_DATA, {
234
- app_user_id: 'user123',
235
- name: 'John Doe',
236
- preferences: {
237
- language: 'en'
238
- }
239
- });
234
+ The library provides an event system for handling voice agent interactions.
240
235
 
241
- // Send screen state
242
- await onwid.Event(EventKeys.SCREEN_STATE, {
243
- screen: 'home',
244
- timestamp: Date.now()
245
- });
246
- ```
236
+ #### `Embed.on(eventKey: EmbedEventKeys, callback: Function)`
247
237
 
248
- ### 4. TypeScript Usage
238
+ Listen to voice agent events.
249
239
 
250
- For TypeScript projects, you can import types for better type safety:
240
+ #### `Embed.Event(eventKey: string, data: any)`
251
241
 
252
- ```tsx
253
- import {
254
- OnwidButton,
255
- useInitialize,
256
- useVoiceAgent,
257
- type UseInitializeProps,
258
- type UseVoiceAgentReturn,
259
- type ApiResponse,
260
- EventKeys
261
- } from '@revrag-ai/embed-react-native';
262
-
263
- // Type-safe initialization
264
- const initProps: UseInitializeProps = {
265
- apiKey: 'your-api-key',
266
- onwidUrl: 'https://your-onwid-server.com',
267
- metadata: {
268
- config: {
269
- theme: 'dark'
270
- }
271
- }
272
- };
242
+ Send custom events to the voice agent.
273
243
 
274
- function MyVoiceComponent() {
275
- useInitialize(initProps);
276
-
277
- const voiceAgent: UseVoiceAgentReturn = useVoiceAgent();
278
-
279
- const handleStartCall = async (): Promise<void> => {
280
- try {
281
- await voiceAgent.initializeVoiceAgent();
282
- } catch (error) {
283
- console.error('Failed to start call:', error);
284
- }
285
- };
244
+ #### Event Types
286
245
 
287
- return (
288
- <View>
289
- <OnwidButton />
290
- <Button title="Start Call" onPress={handleStartCall} />
291
- </View>
292
- );
246
+ ```tsx
247
+ enum EmbedEventKeys {
248
+ USER_DATA = 'user_data',
249
+ SCREEN_STATE = 'state_data'
293
250
  }
294
251
  ```
295
252
 
296
- ### 5. Use the OnWid Button Component
253
+ #### Example
297
254
 
298
255
  ```tsx
299
- import { OnwidButton } from '@revrag-ai/embed-react-native';
300
-
301
- function MyComponent() {
302
- return (
303
- <View>
304
- <OnwidButton />
305
- </View>
306
- );
307
- }
308
- ```
256
+ import { Embed, EmbedEventKeys } from '@revrag-ai/embed-react-native';
309
257
 
310
- ## 📚 API Reference
258
+ // Listen for events
259
+ Embed.on(EmbedEventKeys.USER_DATA, (userData) => {
260
+ console.log('Received user data:', userData);
261
+ // Handle user data updates
262
+ });
311
263
 
312
- ### Hooks
264
+ // Send events
265
+ await Embed.Event('custom_event', {
266
+ action: 'page_view',
267
+ page: 'profile',
268
+ timestamp: Date.now()
269
+ });
270
+ ```
313
271
 
314
- #### `useInitialize(props: UseInitializeProps)`
272
+ ## 🎨 Customization
315
273
 
316
- Initializes the OnWid SDK with your configuration.
274
+ ### Styling the Voice Button
317
275
 
318
- **Props:**
319
- - `apiKey: string` - Your OnWid API key
320
- - `onwidUrl: string` - Your OnWid server URL
321
- - `metadata?: object` - Optional metadata configuration
276
+ The `EmbedButton` component comes with built-in styling but can be customized through the configuration metadata:
322
277
 
323
- #### `useVoiceAgent(): UseVoiceAgentReturn`
278
+ ```tsx
279
+ useInitialize({
280
+ apiKey: 'your-api-key',
281
+ embedUrl: 'your-server-url',
282
+ });
283
+ ```
324
284
 
325
- Provides voice agent functionality.
285
+ ## 🔧 Advanced Usage
326
286
 
327
- **Returns:**
328
- - `initializeVoiceAgent: () => Promise<void>` - Start voice agent
329
- - `endCall: () => Promise<void>` - End the voice call
330
- - `muteMic: () => void` - Mute microphone
331
- - `unmuteMic: () => void` - Unmute microphone
332
- - `isMicMuted: boolean` - Microphone mute state
333
- - `connectionState: ConnectionState` - Current connection state
334
- - `isLoading: boolean` - Loading state
335
- - `error: string | null` - Error message if any
287
+ ### Context Data Management
336
288
 
337
- ### Components
289
+ Provide rich context to your voice agent for more intelligent conversations:
338
290
 
339
- #### `OnwidButton`
291
+ ```tsx
292
+ const contextData = {
293
+ user: {
294
+ id: 'U123456',
295
+ name: 'John Doe',
296
+ accountDetails: {
297
+ balance: 1500.50,
298
+ lastTransaction: '2024-01-15',
299
+ accountType: 'premium'
300
+ }
301
+ },
302
+ currentScreen: 'dashboard',
303
+ availableActions: ['transfer', 'balance_inquiry', 'transaction_history']
304
+ };
340
305
 
341
- A customizable button component with built-in voice agent functionality.
306
+ useInitialize({
307
+ apiKey: 'your-api-key',
308
+ embedUrl: 'your-server-url',
309
+ });
310
+ ```
342
311
 
343
- ### Classes
312
+ ### Error Handling
344
313
 
345
- #### `APIService`
314
+ ```tsx
315
+ import { useVoiceAgent } from '@revrag-ai/embed-react-native';
346
316
 
347
- Singleton service for API communication.
317
+ function VoiceComponent() {
318
+ const { error, initializeVoiceAgent } = useVoiceAgent();
348
319
 
349
- ```tsx
350
- import { APIService } from '@revrag-ai/embed-react-native';
320
+ useEffect(() => {
321
+ if (error) {
322
+ console.error('Voice agent error:', error);
323
+ // Handle error - show user message, retry logic, etc.
324
+ }
325
+ }, [error]);
351
326
 
352
- const apiService = APIService.getInstance();
353
- await apiService.initialize();
327
+ // Rest of component...
328
+ }
354
329
  ```
355
- ### Events
356
330
 
357
- #### `EventKeys`
331
+ ## 🛠 Troubleshooting
358
332
 
359
- Available event types:
360
- - `USER_DATA` - User information events
361
- - `SCREEN_STATE` - Screen state events
333
+ ### Common Issues
362
334
 
363
- ## 🔒 Security
335
+ 1. **Microphone Permission Denied**
336
+ - Ensure you've added the microphone permission to your platform-specific config files
337
+ - Check that users have granted microphone permission
364
338
 
365
- The OnWid SDK includes built-in security features:
339
+ 2. **Connection Issues**
340
+ - Verify your API key is correct
341
+ - Ensure the `embedUrl` is accessible from your app
342
+ - Check network connectivity
366
343
 
367
- - Automatic API key management
368
- - Secure token handling
369
- - Protected API endpoints
370
- - Integrity checks
344
+ 3. **Audio Not Working**
345
+ - Test on a physical device (audio may not work in simulators)
346
+ - Verify audio output settings
347
+ - Check that other apps can use the microphone
371
348
 
372
- ## 🤝 Contributing
349
+ ### Debug Mode
373
350
 
374
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
351
+ Enable detailed logging for debugging:
375
352
 
376
- ## 📄 License
353
+ ```tsx
354
+ // Add this before initializing
355
+ console.log('Voice Agent Debug Mode Enabled');
377
356
 
378
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
357
+ useInitialize({
358
+ apiKey: 'your-api-key',
359
+ embedUrl: 'your-server-url',
360
+ });
361
+ ```
379
362
 
380
- ## 🆘 Support
363
+ ## 📱 Platform Support
381
364
 
382
- - 📧 Email: contact@revrag.ai
383
- - 🐛 Issues: [GitHub Issues](https://github.com/RevRag-ai/embed-react-native/issues)
384
- - 📖 Documentation: [Integration Guide](INTEGRATION_GUIDE.md)
365
+ - **iOS**: 12.0+
366
+ - **Android**: API level 21+ (Android 5.0)
367
+ - **React Native**: 0.70+
385
368
 
386
- ## 🏷️ Version History
369
+ ## 🤝 Contributing
370
+
371
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
387
372
 
388
- ### 1.0.3
389
- - Enhanced APIService with singleton pattern
390
- - Improved error handling and initialization
391
- - Better TypeScript support
392
- - Fixed voice component compatibility
373
+ ## 📄 License
393
374
 
394
- ### 1.0.2
395
- - Initial stable release
396
- - Core voice agent functionality
397
- - Event system implementation
375
+ MIT
398
376
 
399
377
  ---
400
378
 
401
- Made with ❤️ by [RevRag AI](https://www.revrag.ai)
379
+ **Made with ❤️ by [RevRag AI](https://www.revrag.ai)**
402
380
 
381
+ For support, visit our [documentation](https://docs.revrag.ai) or contact us at [contact@revrag.ai](mailto:contact@revrag.ai).
@@ -0,0 +1,15 @@
1
+ cmake_minimum_required(VERSION 3.4.1)
2
+ project(EmbedReactNative)
3
+
4
+ set (CMAKE_VERBOSE_MAKEFILE ON)
5
+ set (CMAKE_CXX_STANDARD 14)
6
+
7
+ add_library(revrag-ai-embed-react-native SHARED
8
+ ../cpp/revrag-ai-embed-react-native.cpp
9
+ cpp-adapter.cpp
10
+ )
11
+
12
+ # Specifies a path to native header files.
13
+ include_directories(
14
+ ../cpp
15
+ )