@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.
Files changed (66) hide show
  1. package/README.md +483 -0
  2. package/ios/README.md +211 -211
  3. package/lib/callkit/callkit-coordinator.d.ts +117 -113
  4. package/lib/callkit/callkit-coordinator.js +727 -681
  5. package/lib/callkit/callkit.d.ts +41 -41
  6. package/lib/callkit/callkit.js +242 -252
  7. package/lib/callkit/index.js +47 -15
  8. package/lib/callkit/use-callkit-coordinator.d.ts +21 -21
  9. package/lib/callkit/use-callkit-coordinator.js +53 -53
  10. package/lib/callkit/use-callkit.d.ts +19 -19
  11. package/lib/callkit/use-callkit.js +310 -270
  12. package/lib/context/TelnyxVoiceContext.d.ts +9 -9
  13. package/lib/context/TelnyxVoiceContext.js +13 -10
  14. package/lib/hooks/use-callkit-coordinator.d.ts +17 -9
  15. package/lib/hooks/use-callkit-coordinator.js +50 -45
  16. package/lib/hooks/useAppReadyNotifier.js +15 -13
  17. package/lib/hooks/useAppStateHandler.d.ts +11 -6
  18. package/lib/hooks/useAppStateHandler.js +110 -95
  19. package/lib/index.d.ts +21 -3
  20. package/lib/index.js +201 -50
  21. package/lib/internal/CallKitHandler.d.ts +6 -6
  22. package/lib/internal/CallKitHandler.js +104 -96
  23. package/lib/internal/callkit-manager.d.ts +57 -57
  24. package/lib/internal/callkit-manager.js +316 -299
  25. package/lib/internal/calls/call-state-controller.d.ts +86 -81
  26. package/lib/internal/calls/call-state-controller.js +307 -269
  27. package/lib/internal/session/session-manager.d.ts +75 -75
  28. package/lib/internal/session/session-manager.js +424 -350
  29. package/lib/internal/user-defaults-helpers.js +39 -49
  30. package/lib/internal/voice-pn-bridge.d.ts +11 -11
  31. package/lib/internal/voice-pn-bridge.js +3 -3
  32. package/lib/models/call-state.d.ts +44 -44
  33. package/lib/models/call-state.js +68 -66
  34. package/lib/models/call.d.ts +133 -133
  35. package/lib/models/call.js +382 -354
  36. package/lib/models/config.d.ts +18 -11
  37. package/lib/models/config.js +35 -37
  38. package/lib/models/connection-state.d.ts +10 -10
  39. package/lib/models/connection-state.js +16 -16
  40. package/lib/telnyx-voice-app.d.ts +28 -28
  41. package/lib/telnyx-voice-app.js +482 -424
  42. package/lib/telnyx-voip-client.d.ts +167 -165
  43. package/lib/telnyx-voip-client.js +390 -383
  44. package/package.json +104 -104
  45. package/src/callkit/callkit-coordinator.ts +846 -846
  46. package/src/callkit/callkit.ts +322 -322
  47. package/src/callkit/index.ts +4 -4
  48. package/src/callkit/use-callkit.ts +345 -345
  49. package/src/context/TelnyxVoiceContext.tsx +33 -33
  50. package/src/hooks/use-callkit-coordinator.ts +60 -60
  51. package/src/hooks/useAppReadyNotifier.ts +25 -25
  52. package/src/hooks/useAppStateHandler.ts +134 -134
  53. package/src/index.ts +56 -56
  54. package/src/internal/CallKitHandler.tsx +149 -149
  55. package/src/internal/callkit-manager.ts +335 -335
  56. package/src/internal/calls/call-state-controller.ts +384 -384
  57. package/src/internal/session/session-manager.ts +467 -467
  58. package/src/internal/user-defaults-helpers.ts +58 -58
  59. package/src/internal/voice-pn-bridge.ts +18 -18
  60. package/src/models/call-state.ts +98 -98
  61. package/src/models/call.ts +388 -388
  62. package/src/models/config.ts +125 -125
  63. package/src/models/connection-state.ts +50 -50
  64. package/src/telnyx-voice-app.tsx +690 -690
  65. package/src/telnyx-voip-client.ts +539 -539
  66. package/src/types/telnyx-sdk.d.ts +79 -79
package/ios/README.md CHANGED
@@ -1,211 +1,211 @@
1
- # Telnyx Voice Commons - iOS Integration
2
-
3
- This document explains how to integrate the iOS CallKit and VoIP push notification functionality into your React Native app.
4
-
5
- ## 📋 **Prerequisites**
6
-
7
- 1. iOS deployment target 13.0 or higher
8
- 2. Valid Apple Developer account with VoIP push notification entitlements
9
- 3. Telnyx account with Voice SDK access
10
-
11
- ## 🚀 **Installation**
12
-
13
- 1. Install the react-voice-commons package
14
- 2. Add VoIP background mode to your Info.plist
15
- 3. Set up your AppDelegate
16
-
17
- ## ⚙️ **Setup**
18
-
19
- ### 1. Info.plist Configuration
20
-
21
- Add the following to your iOS app's `Info.plist`:
22
-
23
- ```xml
24
- <key>UIBackgroundModes</key>
25
- <array>
26
- <string>voip</string>
27
- </array>
28
-
29
- <key>NSMicrophoneUsageDescription</key>
30
- <string>This app needs microphone access to make voice calls</string>
31
- ```
32
-
33
- ### 2. AppDelegate Integration
34
-
35
- #### Option A: Easy Integration (Recommended)
36
-
37
- Import and use the `TelnyxVoiceAppDelegate` protocol:
38
-
39
- ```swift
40
- import TelnyxVoiceCommons
41
-
42
- class AppDelegate: ExpoAppDelegate, TelnyxVoiceAppDelegate {
43
- // Required properties for TelnyxVoiceAppDelegate
44
- var voipRegistry: PKPushRegistry?
45
- var callKitProvider: CXProvider?
46
- var callKitController: CXCallController?
47
- var activeCalls: [UUID: [String: Any]] = [:]
48
-
49
- override func application(
50
- _ application: UIApplication,
51
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
52
- ) -> Bool {
53
- // Your existing setup code...
54
-
55
- // Add Telnyx Voice setup
56
- setupTelnyxVoice()
57
-
58
- return super.application(application, didFinishLaunchingWithOptions: launchOptions)
59
- }
60
-
61
- // Optionally customize CallKit configuration
62
- override func customCallKitConfiguration() -> CXProviderConfiguration {
63
- let configuration = CXProviderConfiguration(localizedName: "My App Voice")
64
- configuration.supportsVideo = false
65
- configuration.maximumCallGroups = 1
66
- configuration.maximumCallsPerCallGroup = 1
67
- configuration.supportedHandleTypes = [.phoneNumber, .generic]
68
- configuration.includesCallsInRecents = true
69
- return configuration
70
- }
71
- }
72
-
73
- // Automatically get PKPushRegistryDelegate methods
74
- extension AppDelegate: PKPushRegistryDelegate {}
75
-
76
- // Automatically get CXProviderDelegate methods
77
- extension AppDelegate: CXProviderDelegate {}
78
- ```
79
-
80
- #### Option B: Manual Integration
81
-
82
- If you prefer to implement the delegates manually:
83
-
84
- ```swift
85
- import PushKit
86
- import CallKit
87
- import AVFoundation
88
-
89
- class AppDelegate: ExpoAppDelegate {
90
- var voipRegistry: PKPushRegistry?
91
- var callKitProvider: CXProvider?
92
- var callKitController: CXCallController?
93
- var activeCalls: [UUID: [String: Any]] = [:]
94
-
95
- override func application(
96
- _ application: UIApplication,
97
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
98
- ) -> Bool {
99
- // Your existing setup...
100
-
101
- setupVoIPPushNotifications()
102
- setupCallKit()
103
-
104
- return super.application(application, didFinishLaunchingWithOptions: launchOptions)
105
- }
106
-
107
- private func setupVoIPPushNotifications() {
108
- voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
109
- voipRegistry?.delegate = self
110
- voipRegistry?.desiredPushTypes = [PKPushType.voIP]
111
- }
112
-
113
- private func setupCallKit() {
114
- let configuration = CXProviderConfiguration(localizedName: "Voice Call")
115
- configuration.supportsVideo = false
116
- configuration.maximumCallGroups = 1
117
- configuration.maximumCallsPerCallGroup = 1
118
- configuration.supportedHandleTypes = [.phoneNumber, .generic]
119
- configuration.includesCallsInRecents = true
120
-
121
- callKitProvider = CXProvider(configuration: configuration)
122
- callKitProvider?.setDelegate(self, queue: nil)
123
- callKitController = CXCallController()
124
- }
125
- }
126
-
127
- extension AppDelegate: PKPushRegistryDelegate {
128
- // Implement push notification methods...
129
- // (See TelnyxVoiceAppDelegate.swift for full implementation)
130
- }
131
-
132
- extension AppDelegate: CXProviderDelegate {
133
- // Implement CallKit delegate methods...
134
- // (See TelnyxVoiceAppDelegate.swift for full implementation)
135
- }
136
- ```
137
-
138
- ## 🔧 **iOS Project Configuration**
139
-
140
- ### 1. Enable VoIP Background Mode
141
-
142
- In Xcode:
143
-
144
- 1. Select your project target
145
- 2. Go to "Signing & Capabilities"
146
- 3. Add "Background Modes" capability
147
- 4. Check "Voice over IP"
148
-
149
- ### 2. Add Push Notification Entitlement
150
-
151
- 1. Add "Push Notifications" capability
152
- 2. Ensure VoIP push notifications are enabled in your Apple Developer account
153
-
154
- ## 📱 **Usage in React Native**
155
-
156
- After setting up the iOS native code, use the library in your React Native code:
157
-
158
- ```typescript
159
- import { createTelnyxVoipClient } from '@telnyx/react-voice-commons-sdk';
160
-
161
- const voipClient = createTelnyxVoipClient({
162
- enableNativeUI: true, // Enable CallKit integration
163
- enableBackgroundHandling: true,
164
- debug: true,
165
- });
166
-
167
- // Login and make calls as usual
168
- await voipClient.login({
169
- sipUser: 'your-sip-user',
170
- sipPassword: 'your-password',
171
- debug: true,
172
- });
173
- ```
174
-
175
- ## 🎯 **Features**
176
-
177
- With this setup, your app will automatically get:
178
-
179
- - ✅ Native iOS CallKit interface for incoming/outgoing calls
180
- - ✅ VoIP push notifications for incoming calls
181
- - ✅ Background call handling
182
- - ✅ Call history integration
183
- - ✅ Native call controls (answer, end, hold)
184
- - ✅ Audio session management
185
- - ✅ Automatic CallKit synchronization
186
-
187
- ## 🐛 **Troubleshooting**
188
-
189
- ### Common Issues:
190
-
191
- 1. **CallKit not showing**: Ensure VoIP background mode is enabled in Info.plist
192
- 2. **Push notifications not working**: Check that VoIP push entitlements are properly configured
193
- 3. **Audio issues**: Verify microphone permissions and audio session setup
194
- 4. **Build errors**: Make sure iOS deployment target is 13.0+
195
-
196
- ### Debug Logs:
197
-
198
- Enable debug logging to see detailed CallKit integration logs:
199
-
200
- ```swift
201
- // In your AppDelegate setup
202
- setupTelnyxVoice()
203
- ```
204
-
205
- Look for logs prefixed with `TelnyxVoice:` in the Xcode console.
206
-
207
- ## 📚 **Additional Resources**
208
-
209
- - [Apple CallKit Documentation](https://developer.apple.com/documentation/callkit)
210
- - [VoIP Push Notifications Guide](https://developer.apple.com/documentation/pushkit)
211
- - [Telnyx Voice API Documentation](https://developers.telnyx.com/docs/v2/voice)
1
+ # Telnyx Voice Commons - iOS Integration
2
+
3
+ This document explains how to integrate the iOS CallKit and VoIP push notification functionality into your React Native app.
4
+
5
+ ## 📋 **Prerequisites**
6
+
7
+ 1. iOS deployment target 13.0 or higher
8
+ 2. Valid Apple Developer account with VoIP push notification entitlements
9
+ 3. Telnyx account with Voice SDK access
10
+
11
+ ## 🚀 **Installation**
12
+
13
+ 1. Install the react-voice-commons package
14
+ 2. Add VoIP background mode to your Info.plist
15
+ 3. Set up your AppDelegate
16
+
17
+ ## ⚙️ **Setup**
18
+
19
+ ### 1. Info.plist Configuration
20
+
21
+ Add the following to your iOS app's `Info.plist`:
22
+
23
+ ```xml
24
+ <key>UIBackgroundModes</key>
25
+ <array>
26
+ <string>voip</string>
27
+ </array>
28
+
29
+ <key>NSMicrophoneUsageDescription</key>
30
+ <string>This app needs microphone access to make voice calls</string>
31
+ ```
32
+
33
+ ### 2. AppDelegate Integration
34
+
35
+ #### Option A: Easy Integration (Recommended)
36
+
37
+ Import and use the `TelnyxVoiceAppDelegate` protocol:
38
+
39
+ ```swift
40
+ import TelnyxVoiceCommons
41
+
42
+ class AppDelegate: ExpoAppDelegate, TelnyxVoiceAppDelegate {
43
+ // Required properties for TelnyxVoiceAppDelegate
44
+ var voipRegistry: PKPushRegistry?
45
+ var callKitProvider: CXProvider?
46
+ var callKitController: CXCallController?
47
+ var activeCalls: [UUID: [String: Any]] = [:]
48
+
49
+ override func application(
50
+ _ application: UIApplication,
51
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
52
+ ) -> Bool {
53
+ // Your existing setup code...
54
+
55
+ // Add Telnyx Voice setup
56
+ setupTelnyxVoice()
57
+
58
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
59
+ }
60
+
61
+ // Optionally customize CallKit configuration
62
+ override func customCallKitConfiguration() -> CXProviderConfiguration {
63
+ let configuration = CXProviderConfiguration(localizedName: "My App Voice")
64
+ configuration.supportsVideo = false
65
+ configuration.maximumCallGroups = 1
66
+ configuration.maximumCallsPerCallGroup = 1
67
+ configuration.supportedHandleTypes = [.phoneNumber, .generic]
68
+ configuration.includesCallsInRecents = true
69
+ return configuration
70
+ }
71
+ }
72
+
73
+ // Automatically get PKPushRegistryDelegate methods
74
+ extension AppDelegate: PKPushRegistryDelegate {}
75
+
76
+ // Automatically get CXProviderDelegate methods
77
+ extension AppDelegate: CXProviderDelegate {}
78
+ ```
79
+
80
+ #### Option B: Manual Integration
81
+
82
+ If you prefer to implement the delegates manually:
83
+
84
+ ```swift
85
+ import PushKit
86
+ import CallKit
87
+ import AVFoundation
88
+
89
+ class AppDelegate: ExpoAppDelegate {
90
+ var voipRegistry: PKPushRegistry?
91
+ var callKitProvider: CXProvider?
92
+ var callKitController: CXCallController?
93
+ var activeCalls: [UUID: [String: Any]] = [:]
94
+
95
+ override func application(
96
+ _ application: UIApplication,
97
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
98
+ ) -> Bool {
99
+ // Your existing setup...
100
+
101
+ setupVoIPPushNotifications()
102
+ setupCallKit()
103
+
104
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
105
+ }
106
+
107
+ private func setupVoIPPushNotifications() {
108
+ voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
109
+ voipRegistry?.delegate = self
110
+ voipRegistry?.desiredPushTypes = [PKPushType.voIP]
111
+ }
112
+
113
+ private func setupCallKit() {
114
+ let configuration = CXProviderConfiguration(localizedName: "Voice Call")
115
+ configuration.supportsVideo = false
116
+ configuration.maximumCallGroups = 1
117
+ configuration.maximumCallsPerCallGroup = 1
118
+ configuration.supportedHandleTypes = [.phoneNumber, .generic]
119
+ configuration.includesCallsInRecents = true
120
+
121
+ callKitProvider = CXProvider(configuration: configuration)
122
+ callKitProvider?.setDelegate(self, queue: nil)
123
+ callKitController = CXCallController()
124
+ }
125
+ }
126
+
127
+ extension AppDelegate: PKPushRegistryDelegate {
128
+ // Implement push notification methods...
129
+ // (See TelnyxVoiceAppDelegate.swift for full implementation)
130
+ }
131
+
132
+ extension AppDelegate: CXProviderDelegate {
133
+ // Implement CallKit delegate methods...
134
+ // (See TelnyxVoiceAppDelegate.swift for full implementation)
135
+ }
136
+ ```
137
+
138
+ ## 🔧 **iOS Project Configuration**
139
+
140
+ ### 1. Enable VoIP Background Mode
141
+
142
+ In Xcode:
143
+
144
+ 1. Select your project target
145
+ 2. Go to "Signing & Capabilities"
146
+ 3. Add "Background Modes" capability
147
+ 4. Check "Voice over IP"
148
+
149
+ ### 2. Add Push Notification Entitlement
150
+
151
+ 1. Add "Push Notifications" capability
152
+ 2. Ensure VoIP push notifications are enabled in your Apple Developer account
153
+
154
+ ## 📱 **Usage in React Native**
155
+
156
+ After setting up the iOS native code, use the library in your React Native code:
157
+
158
+ ```typescript
159
+ import { createTelnyxVoipClient } from '@telnyx/react-voice-commons-sdk';
160
+
161
+ const voipClient = createTelnyxVoipClient({
162
+ enableNativeUI: true, // Enable CallKit integration
163
+ enableBackgroundHandling: true,
164
+ debug: true,
165
+ });
166
+
167
+ // Login and make calls as usual
168
+ await voipClient.login({
169
+ sipUser: 'your-sip-user',
170
+ sipPassword: 'your-password',
171
+ debug: true,
172
+ });
173
+ ```
174
+
175
+ ## 🎯 **Features**
176
+
177
+ With this setup, your app will automatically get:
178
+
179
+ - ✅ Native iOS CallKit interface for incoming/outgoing calls
180
+ - ✅ VoIP push notifications for incoming calls
181
+ - ✅ Background call handling
182
+ - ✅ Call history integration
183
+ - ✅ Native call controls (answer, end, hold)
184
+ - ✅ Audio session management
185
+ - ✅ Automatic CallKit synchronization
186
+
187
+ ## 🐛 **Troubleshooting**
188
+
189
+ ### Common Issues:
190
+
191
+ 1. **CallKit not showing**: Ensure VoIP background mode is enabled in Info.plist
192
+ 2. **Push notifications not working**: Check that VoIP push entitlements are properly configured
193
+ 3. **Audio issues**: Verify microphone permissions and audio session setup
194
+ 4. **Build errors**: Make sure iOS deployment target is 13.0+
195
+
196
+ ### Debug Logs:
197
+
198
+ Enable debug logging to see detailed CallKit integration logs:
199
+
200
+ ```swift
201
+ // In your AppDelegate setup
202
+ setupTelnyxVoice()
203
+ ```
204
+
205
+ Look for logs prefixed with `TelnyxVoice:` in the Xcode console.
206
+
207
+ ## 📚 **Additional Resources**
208
+
209
+ - [Apple CallKit Documentation](https://developer.apple.com/documentation/callkit)
210
+ - [VoIP Push Notifications Guide](https://developer.apple.com/documentation/pushkit)
211
+ - [Telnyx Voice API Documentation](https://developers.telnyx.com/docs/v2/voice)
@@ -8,119 +8,123 @@ import { TelnyxVoipClient } from '../telnyx-voip-client';
8
8
  * guidelines for proper CallKit integration.
9
9
  */
10
10
  declare class CallKitCoordinator {
11
- private static instance;
12
- private callMap;
13
- private processingCalls;
14
- private endedCalls;
15
- private connectedCalls;
16
- private isCallFromPush;
17
- private voipClient;
18
- static getInstance(): CallKitCoordinator;
19
- private constructor();
20
- private setupCallKitListeners;
21
- /**
22
- * Report an incoming call to CallKit (from push notification or socket)
23
- * For push notifications, the call is already reported - we just need to map it
24
- */
25
- reportIncomingCall(call: Call, callerName: string, callerNumber: string): Promise<string | null>;
26
- /**
27
- * Start an outgoing call through CallKit
28
- */
29
- startOutgoingCall(call: Call, destinationNumber: string, displayName?: string): Promise<string | null>;
30
- /**
31
- * Answer a call from the app UI (CallKit-first approach)
32
- */
33
- answerCallFromUI(call: Call): Promise<boolean>;
34
- /**
35
- * End a call from the app UI (CallKit-first approach)
36
- */
37
- endCallFromUI(call: Call): Promise<boolean>;
38
- /**
39
- * Handle CallKit answer action (triggered by CallKit)
40
- */
41
- handleCallKitAnswer(callKitUUID: string, event?: any): Promise<void>;
42
- /**
43
- * Handle CallKit end action (triggered by CallKit)
44
- */
45
- private handleCallKitEnd;
46
- /**
47
- * Handle CallKit start action (triggered by CallKit for outgoing calls)
48
- */
49
- private handleCallKitStart;
50
- /**
51
- * Handle CallKit push received event - when a VoIP push notification has been processed
52
- * This allows us to coordinate between the push notification and any subsequent WebRTC calls
53
- */
54
- handleCallKitPushReceived(callKitUUID: string, event?: any): Promise<void>;
55
- /**
56
- * Handle push notification answer - when user answers from CallKit but we don't have a WebRTC call yet
57
- * This is the iOS equivalent of the Android FCM handler
58
- */
59
- private handlePushNotificationAnswer;
60
- /**
61
- * Handle push notification reject - when user rejects from CallKit but we don't have a WebRTC call yet
62
- * This is the iOS equivalent of the Android FCM handler reject
63
- */
64
- private handlePushNotificationReject;
65
- /**
66
- * Set up listeners for WebRTC call state changes
67
- */
68
- private setupWebRTCCallListeners;
69
- /**
70
- * Clean up call mappings and listeners
71
- */
72
- private cleanupCall;
73
- /**
74
- * Get CallKit UUID for a WebRTC call
75
- */
76
- getCallKitUUID(call: Call): string | null;
77
- /**
78
- * Get WebRTC call for a CallKit UUID
79
- */
80
- getWebRTCCall(callKitUUID: string): Call | null;
81
- /**
82
- * Link an existing CallKit call (from push notification) with a WebRTC call
83
- * This should be called when a WebRTC call arrives that corresponds to an existing CallKit call
84
- */
85
- linkExistingCallKitCall(call: Call, callKitUUID: string): void;
86
- /**
87
- * Set the VoIP client reference for triggering reconnection
88
- */
89
- setVoipClient(voipClient: TelnyxVoipClient): void;
90
- /**
91
- * Helper method to handle auto-answer logic for push notification calls
92
- */
93
- private handleAutoAnswer;
94
- /**
95
- * Helper method to clean up push notification state
96
- */
97
- private cleanupPushNotificationState;
98
- /**
99
- * Get reference to the SDK client (for queuing actions when call doesn't exist yet)
100
- */
101
- private getSDKClient;
102
- /**
103
- * Check if app is in background and disconnect client if no active calls
104
- */
105
- private checkBackgroundDisconnection;
106
- /**
107
- * Reset only flags (keeping active call mappings intact)
108
- */
109
- resetFlags(): void;
110
- /**
111
- * Check if there are any calls currently being processed by CallKit
112
- * This helps prevent premature flag resets during CallKit operations
113
- */
114
- hasProcessingCalls(): boolean;
115
- /**
116
- * Check if there's currently a call from push notification being processed
117
- * This helps prevent disconnection during push call handling
118
- */
119
- getIsCallFromPush(): boolean;
120
- /**
121
- * Check if CallKit is available and coordinator is active
122
- */
123
- isAvailable(): boolean;
11
+ private static instance;
12
+ private callMap;
13
+ private processingCalls;
14
+ private endedCalls;
15
+ private connectedCalls;
16
+ private isCallFromPush;
17
+ private voipClient;
18
+ static getInstance(): CallKitCoordinator;
19
+ private constructor();
20
+ private setupCallKitListeners;
21
+ /**
22
+ * Report an incoming call to CallKit (from push notification or socket)
23
+ * For push notifications, the call is already reported - we just need to map it
24
+ */
25
+ reportIncomingCall(call: Call, callerName: string, callerNumber: string): Promise<string | null>;
26
+ /**
27
+ * Start an outgoing call through CallKit
28
+ */
29
+ startOutgoingCall(
30
+ call: Call,
31
+ destinationNumber: string,
32
+ displayName?: string
33
+ ): Promise<string | null>;
34
+ /**
35
+ * Answer a call from the app UI (CallKit-first approach)
36
+ */
37
+ answerCallFromUI(call: Call): Promise<boolean>;
38
+ /**
39
+ * End a call from the app UI (CallKit-first approach)
40
+ */
41
+ endCallFromUI(call: Call): Promise<boolean>;
42
+ /**
43
+ * Handle CallKit answer action (triggered by CallKit)
44
+ */
45
+ handleCallKitAnswer(callKitUUID: string, event?: any): Promise<void>;
46
+ /**
47
+ * Handle CallKit end action (triggered by CallKit)
48
+ */
49
+ private handleCallKitEnd;
50
+ /**
51
+ * Handle CallKit start action (triggered by CallKit for outgoing calls)
52
+ */
53
+ private handleCallKitStart;
54
+ /**
55
+ * Handle CallKit push received event - when a VoIP push notification has been processed
56
+ * This allows us to coordinate between the push notification and any subsequent WebRTC calls
57
+ */
58
+ handleCallKitPushReceived(callKitUUID: string, event?: any): Promise<void>;
59
+ /**
60
+ * Handle push notification answer - when user answers from CallKit but we don't have a WebRTC call yet
61
+ * This is the iOS equivalent of the Android FCM handler
62
+ */
63
+ private handlePushNotificationAnswer;
64
+ /**
65
+ * Handle push notification reject - when user rejects from CallKit but we don't have a WebRTC call yet
66
+ * This is the iOS equivalent of the Android FCM handler reject
67
+ */
68
+ private handlePushNotificationReject;
69
+ /**
70
+ * Set up listeners for WebRTC call state changes
71
+ */
72
+ private setupWebRTCCallListeners;
73
+ /**
74
+ * Clean up call mappings and listeners
75
+ */
76
+ private cleanupCall;
77
+ /**
78
+ * Get CallKit UUID for a WebRTC call
79
+ */
80
+ getCallKitUUID(call: Call): string | null;
81
+ /**
82
+ * Get WebRTC call for a CallKit UUID
83
+ */
84
+ getWebRTCCall(callKitUUID: string): Call | null;
85
+ /**
86
+ * Link an existing CallKit call (from push notification) with a WebRTC call
87
+ * This should be called when a WebRTC call arrives that corresponds to an existing CallKit call
88
+ */
89
+ linkExistingCallKitCall(call: Call, callKitUUID: string): void;
90
+ /**
91
+ * Set the VoIP client reference for triggering reconnection
92
+ */
93
+ setVoipClient(voipClient: TelnyxVoipClient): void;
94
+ /**
95
+ * Helper method to handle auto-answer logic for push notification calls
96
+ */
97
+ private handleAutoAnswer;
98
+ /**
99
+ * Helper method to clean up push notification state
100
+ */
101
+ private cleanupPushNotificationState;
102
+ /**
103
+ * Get reference to the SDK client (for queuing actions when call doesn't exist yet)
104
+ */
105
+ private getSDKClient;
106
+ /**
107
+ * Check if app is in background and disconnect client if no active calls
108
+ */
109
+ private checkBackgroundDisconnection;
110
+ /**
111
+ * Reset only flags (keeping active call mappings intact)
112
+ */
113
+ resetFlags(): void;
114
+ /**
115
+ * Check if there are any calls currently being processed by CallKit
116
+ * This helps prevent premature flag resets during CallKit operations
117
+ */
118
+ hasProcessingCalls(): boolean;
119
+ /**
120
+ * Check if there's currently a call from push notification being processed
121
+ * This helps prevent disconnection during push call handling
122
+ */
123
+ getIsCallFromPush(): boolean;
124
+ /**
125
+ * Check if CallKit is available and coordinator is active
126
+ */
127
+ isAvailable(): boolean;
124
128
  }
125
129
  export declare const callKitCoordinator: CallKitCoordinator;
126
130
  export default callKitCoordinator;