@telnyx/react-voice-commons-sdk 0.1.1 → 0.1.2
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.
- package/README.md +483 -0
- package/ios/README.md +211 -211
- package/lib/callkit/callkit-coordinator.d.ts +117 -113
- package/lib/callkit/callkit-coordinator.js +727 -681
- package/lib/callkit/callkit.d.ts +41 -41
- package/lib/callkit/callkit.js +242 -252
- package/lib/callkit/index.js +47 -15
- package/lib/callkit/use-callkit-coordinator.d.ts +21 -21
- package/lib/callkit/use-callkit-coordinator.js +53 -53
- package/lib/callkit/use-callkit.d.ts +19 -19
- package/lib/callkit/use-callkit.js +310 -270
- package/lib/context/TelnyxVoiceContext.d.ts +9 -9
- package/lib/context/TelnyxVoiceContext.js +13 -10
- package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
- package/lib/hooks/use-callkit-coordinator.js +50 -45
- package/lib/hooks/useAppReadyNotifier.js +15 -13
- package/lib/hooks/useAppStateHandler.d.ts +11 -6
- package/lib/hooks/useAppStateHandler.js +110 -95
- package/lib/index.d.ts +21 -3
- package/lib/index.js +201 -50
- package/lib/internal/CallKitHandler.d.ts +6 -6
- package/lib/internal/CallKitHandler.js +104 -96
- package/lib/internal/callkit-manager.d.ts +57 -57
- package/lib/internal/callkit-manager.js +316 -299
- package/lib/internal/calls/call-state-controller.d.ts +86 -81
- package/lib/internal/calls/call-state-controller.js +307 -269
- package/lib/internal/session/session-manager.d.ts +75 -75
- package/lib/internal/session/session-manager.js +424 -350
- package/lib/internal/user-defaults-helpers.js +39 -49
- package/lib/internal/voice-pn-bridge.d.ts +11 -11
- package/lib/internal/voice-pn-bridge.js +3 -3
- package/lib/models/call-state.d.ts +44 -44
- package/lib/models/call-state.js +68 -66
- package/lib/models/call.d.ts +133 -133
- package/lib/models/call.js +382 -354
- package/lib/models/config.d.ts +18 -11
- package/lib/models/config.js +35 -37
- package/lib/models/connection-state.d.ts +10 -10
- package/lib/models/connection-state.js +16 -16
- package/lib/telnyx-voice-app.d.ts +28 -28
- package/lib/telnyx-voice-app.js +482 -424
- package/lib/telnyx-voip-client.d.ts +167 -165
- package/lib/telnyx-voip-client.js +390 -383
- package/package.json +104 -104
- package/src/callkit/callkit-coordinator.ts +846 -846
- package/src/callkit/callkit.ts +322 -322
- package/src/callkit/index.ts +4 -4
- package/src/callkit/use-callkit.ts +345 -345
- package/src/context/TelnyxVoiceContext.tsx +33 -33
- package/src/hooks/use-callkit-coordinator.ts +60 -60
- package/src/hooks/useAppReadyNotifier.ts +25 -25
- package/src/hooks/useAppStateHandler.ts +134 -134
- package/src/index.ts +56 -56
- package/src/internal/CallKitHandler.tsx +149 -149
- package/src/internal/callkit-manager.ts +335 -335
- package/src/internal/calls/call-state-controller.ts +384 -384
- package/src/internal/session/session-manager.ts +467 -467
- package/src/internal/user-defaults-helpers.ts +58 -58
- package/src/internal/voice-pn-bridge.ts +18 -18
- package/src/models/call-state.ts +98 -98
- package/src/models/call.ts +388 -388
- package/src/models/config.ts +125 -125
- package/src/models/connection-state.ts +50 -50
- package/src/telnyx-voice-app.tsx +690 -690
- package/src/telnyx-voip-client.ts +539 -539
- package/src/types/telnyx-sdk.d.ts +79 -79
package/README.md
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
# Telnyx React Native Voice SDK Demo
|
|
2
|
+
|
|
3
|
+
A comprehensive demo application showcasing the **@telnyx/react-voice-commons-sdk** library - a high-level, state-agnostic, drop-in module for the Telnyx React Native SDK that simplifies WebRTC voice calling integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This demo app demonstrates how to integrate the `@telnyx/react-voice-commons-sdk` library to create a fully functional VoIP calling application with native call UI support, push notifications, and background handling.
|
|
8
|
+
|
|
9
|
+
### Key Features Demonstrated
|
|
10
|
+
|
|
11
|
+
- **TelnyxVoiceApp Integration**: Automatic lifecycle management and push notification handling
|
|
12
|
+
- **Native Call UI**: CallKit (iOS) and ConnectionService (Android) integration
|
|
13
|
+
- **Background Handling**: Seamless app state transitions and background call processing
|
|
14
|
+
- **Push Notifications**: Firebase (Android) and APNs (iOS) integration
|
|
15
|
+
- **Reactive State Management**: RxJS-based state streams for real-time UI updates
|
|
16
|
+
- **Modern UI Components**: Built with NativeWind v4 and react-native-reusables
|
|
17
|
+
- **Dark/Light Mode**: Persistent theme support with system navigation bar matching
|
|
18
|
+
|
|
19
|
+
## About @telnyx/react-voice-commons-sdk
|
|
20
|
+
|
|
21
|
+
The `@telnyx/react-voice-commons-sdk` library provides:
|
|
22
|
+
|
|
23
|
+
- **Headless Operation**: Core library that can establish and manage call state programmatically
|
|
24
|
+
- **Reactive Streams**: All state exposed via RxJS observables for easy integration
|
|
25
|
+
- **Simplified API**: Single facade class (`TelnyxVoipClient`) that hides underlying complexity
|
|
26
|
+
- **Automatic Lifecycle Management**: Background/foreground handling with `TelnyxVoiceApp` component
|
|
27
|
+
- **Call State Management**: Central state machine for managing multiple calls
|
|
28
|
+
- **Session Management**: Automatic connection lifecycle with reconnection logic
|
|
29
|
+
- **Push Notification Support**: Built-in handling for background push notifications
|
|
30
|
+
- **TypeScript Support**: Full TypeScript definitions for better developer experience
|
|
31
|
+
|
|
32
|
+
## Integration Guide
|
|
33
|
+
|
|
34
|
+
### Basic Setup
|
|
35
|
+
|
|
36
|
+
The demo shows how to integrate the library using the `TelnyxVoiceApp` component for automatic lifecycle management:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { TelnyxVoiceApp, createTelnyxVoipClient } from '@telnyx/react-voice-commons-sdk';
|
|
40
|
+
|
|
41
|
+
// Create the VoIP client instance
|
|
42
|
+
const voipClient = createTelnyxVoipClient({
|
|
43
|
+
enableAppStateManagement: true, // Optional: Enable automatic app state management (default: true)
|
|
44
|
+
debug: true, // Optional: Enable debug logging
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default function App() {
|
|
48
|
+
return (
|
|
49
|
+
<TelnyxVoiceApp voipClient={voipClient} enableAutoReconnect={false} debug={true}>
|
|
50
|
+
<YourAppContent />
|
|
51
|
+
</TelnyxVoiceApp>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Core Components Used in Demo
|
|
57
|
+
|
|
58
|
+
#### 1. VoIP Client Configuration
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
const voipClient = createTelnyxVoipClient({
|
|
62
|
+
enableAppStateManagement: true, // Optional: Enable automatic app state management (default: true)
|
|
63
|
+
debug: true, // Optional: Enable debug logging
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Configuration Options Explained:**
|
|
68
|
+
|
|
69
|
+
- **`enableAppStateManagement: true`** - **Optional (default: true)**: Enables automatic background/foreground app state management. When enabled, the library automatically disconnects when the app goes to background (unless there's an active call) and handles reconnection logic. Set to `false` if you want to handle app lifecycle manually.
|
|
70
|
+
- **`debug: true`** - **Optional**: Enables detailed logging for connection states, call transitions, and push notification processing. Useful for development and troubleshooting.
|
|
71
|
+
|
|
72
|
+
#### 2. TelnyxVoiceApp Wrapper
|
|
73
|
+
|
|
74
|
+
The `TelnyxVoiceApp` component handles:
|
|
75
|
+
|
|
76
|
+
- Automatic background/foreground lifecycle management
|
|
77
|
+
- Push notification processing from terminated state
|
|
78
|
+
- Login state management with automatic reconnection
|
|
79
|
+
- Background client management for push notifications
|
|
80
|
+
|
|
81
|
+
#### 3. Reactive State Management
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Listen to connection state
|
|
85
|
+
voipClient.connectionState$.subscribe((state) => {
|
|
86
|
+
console.log('Connection state:', state);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Listen to active calls
|
|
90
|
+
voipClient.calls$.subscribe((calls) => {
|
|
91
|
+
console.log('Active calls:', calls);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Handle individual call state
|
|
95
|
+
call.callState$.subscribe((state) => {
|
|
96
|
+
console.log('Call state:', state);
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### 4. Call Management
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
// Make a call
|
|
104
|
+
const call = await voipClient.newCall('1234567890');
|
|
105
|
+
|
|
106
|
+
// Answer incoming call
|
|
107
|
+
await call.answer();
|
|
108
|
+
|
|
109
|
+
// Control call
|
|
110
|
+
await call.mute();
|
|
111
|
+
await call.hold();
|
|
112
|
+
await call.hangup();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Authentication & Persistent Storage
|
|
116
|
+
|
|
117
|
+
The library supports both credential-based and token-based authentication with automatic persistence for seamless reconnection.
|
|
118
|
+
|
|
119
|
+
#### Authentication Methods
|
|
120
|
+
|
|
121
|
+
##### 1. Credential-Based Authentication
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { createCredentialConfig } from '@telnyx/react-voice-commons-sdk';
|
|
125
|
+
|
|
126
|
+
const config = createCredentialConfig('your_sip_username', 'your_sip_password', {
|
|
127
|
+
debug: true,
|
|
128
|
+
pushNotificationDeviceToken: 'your_device_token',
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await voipClient.login(config);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
##### 2. Token-Based Authentication
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
import { createTokenConfig } from '@telnyx/react-voice-commons-sdk';
|
|
138
|
+
|
|
139
|
+
const config = createTokenConfig('your_jwt_token', {
|
|
140
|
+
debug: true,
|
|
141
|
+
pushNotificationDeviceToken: 'your_device_token',
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
await voipClient.loginWithToken(config);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Automatic Storage & Reconnection
|
|
148
|
+
|
|
149
|
+
The library automatically stores authentication data securely for seamless reconnection. **You don't need to manually manage these storage keys** - the library handles everything internally.
|
|
150
|
+
|
|
151
|
+
##### Internal Storage (Managed Automatically)
|
|
152
|
+
|
|
153
|
+
The library uses these AsyncStorage keys internally:
|
|
154
|
+
|
|
155
|
+
- `@telnyx_username` - SIP username (credential auth)
|
|
156
|
+
- `@telnyx_password` - SIP password (credential auth)
|
|
157
|
+
- `@credential_token` - JWT authentication token (token auth)
|
|
158
|
+
- `@push_token` - Push notification device token
|
|
159
|
+
|
|
160
|
+
**Note**: These are managed automatically by the library. You only need to call `login()` once, and the library will handle storage and future reconnections.
|
|
161
|
+
|
|
162
|
+
##### Auto-Reconnection
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
// Automatically reconnects using internally stored credentials or token
|
|
166
|
+
const success = await voipClient.loginFromStoredConfig();
|
|
167
|
+
|
|
168
|
+
if (!success) {
|
|
169
|
+
// No stored authentication data found, show login UI
|
|
170
|
+
console.log('Please log in again');
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**When Auto-Reconnection Happens:**
|
|
175
|
+
|
|
176
|
+
- App launches from background/terminated state
|
|
177
|
+
- Push notification received while disconnected
|
|
178
|
+
- Network reconnection after connectivity loss
|
|
179
|
+
- App state changes (foreground/background transitions)
|
|
180
|
+
|
|
181
|
+
**Demo App Note**: The demo app's `TelnyxLoginForm` component does additional storage for UI convenience (pre-filling the login form). This is separate from the library's internal authentication storage and is not required for production apps.
|
|
182
|
+
|
|
183
|
+
##### Manual Storage Management (Advanced Use Only)
|
|
184
|
+
|
|
185
|
+
If you need to clear stored authentication data manually:
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
189
|
+
|
|
190
|
+
// Clear all Telnyx authentication data
|
|
191
|
+
await AsyncStorage.multiRemove([
|
|
192
|
+
'@telnyx_username',
|
|
193
|
+
'@telnyx_password',
|
|
194
|
+
'@credential_token',
|
|
195
|
+
'@push_token',
|
|
196
|
+
]);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Important**: This is typically not needed. The library manages authentication storage automatically. Only use this for advanced scenarios like implementing a "logout" feature that clears all stored data.
|
|
200
|
+
|
|
201
|
+
### Native Integration
|
|
202
|
+
|
|
203
|
+
The demo app shows complete native integration for both platforms. These integrations are required for production apps using the library.
|
|
204
|
+
|
|
205
|
+
#### Android Integration
|
|
206
|
+
|
|
207
|
+
##### 1. MainActivity Setup
|
|
208
|
+
|
|
209
|
+
Your app's MainActivity should extend `TelnyxMainActivity` for automatic push notification handling:
|
|
210
|
+
|
|
211
|
+
```kotlin
|
|
212
|
+
// In your app's MainActivity.kt
|
|
213
|
+
import com.telnyx.react_voice_commons.TelnyxMainActivity
|
|
214
|
+
|
|
215
|
+
class MainActivity : TelnyxMainActivity() {
|
|
216
|
+
// Your app-specific code
|
|
217
|
+
|
|
218
|
+
override fun onHandleIntent(intent: Intent) {
|
|
219
|
+
super.onHandleIntent(intent)
|
|
220
|
+
// Handle any additional intent processing
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The `TelnyxMainActivity` provides:
|
|
226
|
+
|
|
227
|
+
- Automatic push notification intent handling
|
|
228
|
+
- Call action processing (Answer/Decline from notifications)
|
|
229
|
+
- Proper lifecycle management for VoIP functionality
|
|
230
|
+
- Integration with `VoicePnManager` for push notification state
|
|
231
|
+
|
|
232
|
+
##### 2. Push Notification Setup
|
|
233
|
+
|
|
234
|
+
1. Place `google-services.json` in the project root
|
|
235
|
+
2. Register background message handler:
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
import messaging from '@react-native-firebase/messaging';
|
|
239
|
+
import { TelnyxVoiceApp } from '@telnyx/react-voice-commons-sdk';
|
|
240
|
+
|
|
241
|
+
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
|
|
242
|
+
await TelnyxVoiceApp.handleBackgroundPush(remoteMessage.data);
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### iOS Integration
|
|
247
|
+
|
|
248
|
+
##### 1. AppDelegate Setup
|
|
249
|
+
|
|
250
|
+
Your AppDelegate only needs to implement `PKPushRegistryDelegate` for VoIP push notifications. CallKit integration is automatically handled by CallBridge:
|
|
251
|
+
|
|
252
|
+
```swift
|
|
253
|
+
import PushKit
|
|
254
|
+
import TelnyxVoiceCommons
|
|
255
|
+
|
|
256
|
+
@UIApplicationMain
|
|
257
|
+
public class AppDelegate: ExpoAppDelegate, PKPushRegistryDelegate {
|
|
258
|
+
|
|
259
|
+
public override func application(
|
|
260
|
+
_ application: UIApplication,
|
|
261
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
262
|
+
) -> Bool {
|
|
263
|
+
// Your existing setup...
|
|
264
|
+
|
|
265
|
+
// Initialize VoIP push registry via react-voice-commons
|
|
266
|
+
TelnyxVoipPushHandler.initializeVoipRegistration()
|
|
267
|
+
|
|
268
|
+
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// MARK: - VoIP Push Notifications
|
|
272
|
+
public func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
|
|
273
|
+
TelnyxVoipPushHandler.shared.handleVoipTokenUpdate(pushCredentials, type: type)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
public func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
|
|
277
|
+
TelnyxVoipPushHandler.shared.handleVoipPush(payload, type: type, completion: completion)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Note**: CallKit integration (CXProvider, CXProviderDelegate, audio session management) is automatically handled by the internal CallBridge component. You don't need to implement any CallKit delegate methods manually.
|
|
283
|
+
|
|
284
|
+
##### 2. VoIP Push Certificate Setup
|
|
285
|
+
|
|
286
|
+
- Configure VoIP push certificates in your Apple Developer account
|
|
287
|
+
- The `TelnyxVoipPushHandler` automatically handles token registration and push processing
|
|
288
|
+
- CallKit integration is automatically managed by CallBridge - no manual setup required
|
|
289
|
+
|
|
290
|
+
#### Key Native Features Integrated
|
|
291
|
+
|
|
292
|
+
1. **Push Notification Handling**: Both platforms handle background push notifications properly
|
|
293
|
+
2. **Native Call UI**: CallKit (iOS, managed by CallBridge) and ConnectionService (Android) integration
|
|
294
|
+
3. **Audio Session Management**: Automatic audio session handling for VoIP calls via CallBridge
|
|
295
|
+
4. **Background Processing**: Seamless app state transitions and background call handling
|
|
296
|
+
5. **Intent Processing**: Android intent handling for notification actions (Answer/Decline)
|
|
297
|
+
6. **Token Management**: Automatic push token registration and updates
|
|
298
|
+
|
|
299
|
+
## Running the Demo Application
|
|
300
|
+
|
|
301
|
+
### Prerequisites
|
|
302
|
+
|
|
303
|
+
- Node.js and npm
|
|
304
|
+
- Expo CLI
|
|
305
|
+
- iOS development: Xcode
|
|
306
|
+
- Android development: Android Studio
|
|
307
|
+
|
|
308
|
+
### Installation and Setup
|
|
309
|
+
|
|
310
|
+
1. **Remove global Expo CLI** (if previously installed):
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
npm uninstall -g expo
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
2. **Install dependencies** (including local Expo):
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
npm install
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
3. **Run Expo install** to ensure all dependencies are properly configured:
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
npx expo install
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
4. **Configure Firebase for Android**:
|
|
329
|
+
- Download the `google-services.json` file from your Firebase project
|
|
330
|
+
- Place it in the root directory of the project
|
|
331
|
+
|
|
332
|
+
5. **Prebuild the project**:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
npx expo prebuild
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
6. **Install iOS dependencies** (required for iOS):
|
|
339
|
+
```bash
|
|
340
|
+
cd ios && pod install && cd ..
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Running the Application
|
|
344
|
+
|
|
345
|
+
1. **Start Metro bundler** (in a separate terminal):
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
npx expo start --clear --reset-cache
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
2. **Run on iOS**:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
npx expo run:ios
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
3. **Run on Android**:
|
|
358
|
+
```bash
|
|
359
|
+
npx expo run:android
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
> **Note**: Make sure you have the necessary development environment set up for iOS (Xcode) or Android (Android Studio) before running the respective commands.
|
|
363
|
+
|
|
364
|
+
### Demo App Features
|
|
365
|
+
|
|
366
|
+
Once running, the demo app provides:
|
|
367
|
+
|
|
368
|
+
- **Login Form**: Enter your Telnyx SIP credentials or token
|
|
369
|
+
- **Dialer Interface**: Make outgoing calls with a native dialer UI
|
|
370
|
+
- **Call Management**: Answer, decline, hold, mute, and transfer calls
|
|
371
|
+
- **Native Call UI**: Integrated CallKit (iOS) and ConnectionService (Android)
|
|
372
|
+
- **Push Notifications**: Receive calls when app is in background or terminated
|
|
373
|
+
- **Multiple Call Support**: Handle multiple simultaneous calls
|
|
374
|
+
- **Background Handling**: Seamless app state transitions
|
|
375
|
+
|
|
376
|
+
### Configuration
|
|
377
|
+
|
|
378
|
+
The demo app includes debug logging enabled by default:
|
|
379
|
+
|
|
380
|
+
```tsx
|
|
381
|
+
// Enable debug logging for the Telnyx SDK
|
|
382
|
+
if (__DEV__) {
|
|
383
|
+
log.setLevel('debug');
|
|
384
|
+
(global as any).__TELNYX_DEBUG__ = true;
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
This provides detailed logging for:
|
|
389
|
+
|
|
390
|
+
- Connection state changes
|
|
391
|
+
- Call state transitions
|
|
392
|
+
- Push notification processing
|
|
393
|
+
- Background lifecycle events
|
|
394
|
+
|
|
395
|
+
## Troubleshooting
|
|
396
|
+
|
|
397
|
+
### iOS Connection Issues (First Run)
|
|
398
|
+
|
|
399
|
+
If you encounter network connection errors on iOS:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
# Try clearing cache and resetting
|
|
403
|
+
npx expo start --clear --reset-cache
|
|
404
|
+
|
|
405
|
+
# Or use tunnel mode
|
|
406
|
+
npx expo start --tunnel
|
|
407
|
+
|
|
408
|
+
# Or specify host explicitly
|
|
409
|
+
npx expo start --host lan
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### iOS VoIP Push Notification Issues
|
|
413
|
+
|
|
414
|
+
If you see VoIP-related crashes on iOS, ensure your AppDelegate.swift includes the VoIP push notification delegate methods. The project includes these by default, but if you encounter issues, rebuild the iOS project:
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
npx expo prebuild --platform ios --clean
|
|
418
|
+
npx expo run:ios
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Common Integration Issues
|
|
422
|
+
|
|
423
|
+
#### Double Login
|
|
424
|
+
|
|
425
|
+
Ensure you're not calling login methods manually when using `TelnyxVoiceApp` with auto-reconnection enabled.
|
|
426
|
+
|
|
427
|
+
#### Background Disconnection
|
|
428
|
+
|
|
429
|
+
Check if `enableAutoReconnect` is set appropriately for your use case in the `TelnyxVoiceApp` configuration.
|
|
430
|
+
|
|
431
|
+
#### Push Notifications Not Working
|
|
432
|
+
|
|
433
|
+
- **Android**:
|
|
434
|
+
- Verify `google-services.json` is in the correct location and Firebase is properly configured
|
|
435
|
+
- Ensure your MainActivity extends `TelnyxMainActivity`
|
|
436
|
+
- Check that `VoicePnManager` is properly handling push actions
|
|
437
|
+
- **iOS**:
|
|
438
|
+
- Ensure VoIP push certificates are configured in your Apple Developer account
|
|
439
|
+
- Verify AppDelegate implements `PKPushRegistryDelegate` and delegates to `TelnyxVoipPushHandler`
|
|
440
|
+
- Check that `TelnyxVoipPushHandler.initializeVoipRegistration()` is called in `didFinishLaunchingWithOptions`
|
|
441
|
+
- **Both**: Check that background message handlers are properly registered
|
|
442
|
+
|
|
443
|
+
#### Native Integration Issues
|
|
444
|
+
|
|
445
|
+
- **Android**: Ensure MainActivity extends `TelnyxMainActivity` for proper intent handling
|
|
446
|
+
- **iOS**: Verify AppDelegate implements `PKPushRegistryDelegate` and delegates to `TelnyxVoipPushHandler`
|
|
447
|
+
- **CallKit**: On iOS, CallKit integration is automatically handled by CallBridge - no manual setup required
|
|
448
|
+
|
|
449
|
+
#### Audio Issues
|
|
450
|
+
|
|
451
|
+
- **iOS**: Audio session management is automatically handled by CallBridge
|
|
452
|
+
- **Android**: Verify ConnectionService is properly configured for audio routing
|
|
453
|
+
- **Both**: Ensure proper audio permissions are granted
|
|
454
|
+
|
|
455
|
+
#### Memory Leaks
|
|
456
|
+
|
|
457
|
+
Ensure you're unsubscribing from RxJS observables in your React components:
|
|
458
|
+
|
|
459
|
+
```tsx
|
|
460
|
+
useEffect(() => {
|
|
461
|
+
const subscription = voipClient.connectionState$.subscribe(handleStateChange);
|
|
462
|
+
return () => subscription.unsubscribe();
|
|
463
|
+
}, []);
|
|
464
|
+
}, []);
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
## Documentation
|
|
468
|
+
|
|
469
|
+
For complete API documentation and advanced usage patterns, see the [TelnyxVoiceApp Documentation](./react-voice-commons-sdk/TELNYX_VOICE_APP.md).
|
|
470
|
+
|
|
471
|
+
## Contributing
|
|
472
|
+
|
|
473
|
+
When contributing to this demo or the underlying library:
|
|
474
|
+
|
|
475
|
+
1. Maintain compatibility with both iOS and Android platforms
|
|
476
|
+
2. Add comprehensive tests for new features
|
|
477
|
+
3. Update documentation for any API changes
|
|
478
|
+
4. Follow the existing code style and patterns
|
|
479
|
+
5. Test with both foreground and background scenarios
|
|
480
|
+
|
|
481
|
+
## License
|
|
482
|
+
|
|
483
|
+
MIT License - see LICENSE file for details.
|