@capgo/capacitor-twilio-voice 7.6.2 → 7.6.4
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 +2 -2
- package/android/src/main/java/ee/forgr/capacitor_twilio_voice/CapacitorTwilioVoicePlugin.java +1 -1
- package/dist/docs.json +10 -2
- package/dist/esm/definitions.d.ts +11 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -0
- package/dist/esm/web.js.map +1 -1
- package/ios/Sources/CapacitorTwilioVoicePlugin/CapacitorTwilioVoicePlugin.swift +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -701,7 +701,7 @@ When enabled, audio will be routed through the device's speaker instead of the e
|
|
|
701
701
|
### getCallStatus()
|
|
702
702
|
|
|
703
703
|
```typescript
|
|
704
|
-
getCallStatus() => Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string; callState?: string; }>
|
|
704
|
+
getCallStatus() => Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string; callState?: string; pendingInvites: number; activeCallsCount: number; }>
|
|
705
705
|
```
|
|
706
706
|
|
|
707
707
|
Get the current status of the active call.
|
|
@@ -709,7 +709,7 @@ Get the current status of the active call.
|
|
|
709
709
|
This provides real-time information about the call state, mute status,
|
|
710
710
|
hold status, and call identifiers.
|
|
711
711
|
|
|
712
|
-
**Returns:** <code>Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string; callState?: string; }></code>
|
|
712
|
+
**Returns:** <code>Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string; callState?: string; pendingInvites: number; activeCallsCount: number; }></code>
|
|
713
713
|
|
|
714
714
|
--------------------
|
|
715
715
|
|
package/android/src/main/java/ee/forgr/capacitor_twilio_voice/CapacitorTwilioVoicePlugin.java
CHANGED
|
@@ -75,7 +75,7 @@ import org.json.JSONObject;
|
|
|
75
75
|
)
|
|
76
76
|
public class CapacitorTwilioVoicePlugin extends Plugin {
|
|
77
77
|
|
|
78
|
-
private final String PLUGIN_VERSION = "7.6.
|
|
78
|
+
private final String PLUGIN_VERSION = "7.6.4";
|
|
79
79
|
|
|
80
80
|
private static final String TAG = "CapacitorTwilioVoice";
|
|
81
81
|
private static final String PREF_ACCESS_TOKEN = "twilio_access_token";
|
package/dist/docs.json
CHANGED
|
@@ -305,9 +305,9 @@
|
|
|
305
305
|
},
|
|
306
306
|
{
|
|
307
307
|
"name": "getCallStatus",
|
|
308
|
-
"signature": "() => Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string; callState?: string; }>",
|
|
308
|
+
"signature": "() => Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string; callState?: string; pendingInvites: number; activeCallsCount: number; }>",
|
|
309
309
|
"parameters": [],
|
|
310
|
-
"returns": "Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string | undefined; callState?: string | undefined; }>",
|
|
310
|
+
"returns": "Promise<{ hasActiveCall: boolean; isOnHold: boolean; isMuted: boolean; callSid?: string | undefined; callState?: string | undefined; pendingInvites: number; activeCallsCount: number; }>",
|
|
311
311
|
"tags": [
|
|
312
312
|
{
|
|
313
313
|
"name": "returns",
|
|
@@ -333,6 +333,14 @@
|
|
|
333
333
|
"name": "returns",
|
|
334
334
|
"text": "callState - Current state of the call (e.g., 'connecting', 'connected', 'ringing')"
|
|
335
335
|
},
|
|
336
|
+
{
|
|
337
|
+
"name": "returns",
|
|
338
|
+
"text": "pendingInvites - Number of pending incoming call invitations"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "returns",
|
|
342
|
+
"text": "activeCallsCount - Total number of active calls being tracked"
|
|
343
|
+
},
|
|
336
344
|
{
|
|
337
345
|
"name": "example",
|
|
338
346
|
"text": "```typescript\nconst status = await CapacitorTwilioVoice.getCallStatus();\nif (status.hasActiveCall) {\n console.log('Call SID:', status.callSid);\n console.log('Call State:', status.callState);\n console.log('Is Muted:', status.isMuted);\n console.log('Is On Hold:', status.isOnHold);\n}\n```"
|
|
@@ -266,6 +266,8 @@ export interface CapacitorTwilioVoicePlugin {
|
|
|
266
266
|
* @returns isMuted - Whether the microphone is muted
|
|
267
267
|
* @returns callSid - Unique identifier of the active call (if any)
|
|
268
268
|
* @returns callState - Current state of the call (e.g., 'connecting', 'connected', 'ringing')
|
|
269
|
+
* @returns pendingInvites - Number of pending incoming call invitations
|
|
270
|
+
* @returns activeCallsCount - Total number of active calls being tracked
|
|
269
271
|
*
|
|
270
272
|
* @example
|
|
271
273
|
* ```typescript
|
|
@@ -279,11 +281,20 @@ export interface CapacitorTwilioVoicePlugin {
|
|
|
279
281
|
* ```
|
|
280
282
|
*/
|
|
281
283
|
getCallStatus(): Promise<{
|
|
284
|
+
/** Whether there is currently an active call */
|
|
282
285
|
hasActiveCall: boolean;
|
|
286
|
+
/** Whether the active call is on hold */
|
|
283
287
|
isOnHold: boolean;
|
|
288
|
+
/** Whether the active call is muted */
|
|
284
289
|
isMuted: boolean;
|
|
290
|
+
/** The unique identifier (SID) for the active call */
|
|
285
291
|
callSid?: string;
|
|
292
|
+
/** Current state: 'idle', 'connecting', 'ringing', 'connected', 'reconnecting', 'disconnected', or 'unknown' */
|
|
286
293
|
callState?: string;
|
|
294
|
+
/** Number of pending incoming call invitations */
|
|
295
|
+
pendingInvites: number;
|
|
296
|
+
/** Total number of active calls being tracked */
|
|
297
|
+
activeCallsCount: number;
|
|
287
298
|
}>;
|
|
288
299
|
/**
|
|
289
300
|
* Check if microphone permission has been granted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Capacitor plugin for integrating Twilio Voice functionality into mobile applications.\n *\n * This plugin provides comprehensive voice call capabilities including:\n * - User authentication with Twilio access tokens\n * - Making and receiving phone calls\n * - Call management (accept, reject, end, mute)\n * - Audio routing controls (speaker mode)\n * - Real-time call status monitoring\n * - Event-driven architecture for call lifecycle events\n * - Microphone permission handling\n *\n * @example\n * ```typescript\n * import { CapacitorTwilioVoice } from 'capacitor-twilio-voice';\n *\n * // Login with access token\n * await CapacitorTwilioVoice.login({ accessToken: 'your-twilio-token' });\n *\n * // Make a call\n * await CapacitorTwilioVoice.makeCall({ to: '+1234567890' });\n *\n * // Listen for incoming calls\n * CapacitorTwilioVoice.addListener('callInviteReceived', (data) => {\n * console.log('Incoming call from:', data.from);\n * });\n * ```\n */\nexport interface CapacitorTwilioVoicePlugin {\n // Authentication\n\n /**\n * Authenticate the user with Twilio Voice using an access token.\n *\n * The access token should be generated on your backend server using your Twilio credentials.\n * This token is required to make and receive calls through Twilio Voice.\n *\n * @param options - Configuration object\n * @param options.accessToken - Twilio access token obtained from your backend server\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.login({\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'\n * });\n * console.log('Login successful:', result.success);\n * ```\n */\n login(options: { accessToken: string }): Promise<{ success: boolean }>;\n\n /**\n * Log out the current user and unregister from Twilio Voice.\n *\n * This will disconnect any active calls and stop the device from receiving\n * new incoming call notifications.\n *\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.logout();\n * console.log('Logout successful:', result.success);\n * ```\n */\n logout(): Promise<{ success: boolean }>;\n\n /**\n * Check if the user is currently logged in and has a valid access token.\n *\n * @returns Promise that resolves with login status information\n * @returns isLoggedIn - Whether the user is currently logged in\n * @returns hasValidToken - Whether the access token is still valid\n * @returns identity - The user's Twilio identity (if logged in)\n *\n * @example\n * ```typescript\n * const status = await CapacitorTwilioVoice.isLoggedIn();\n * if (status.isLoggedIn && status.hasValidToken) {\n * console.log('User identity:', status.identity);\n * } else {\n * // Re-authenticate the user\n * }\n * ```\n */\n isLoggedIn(): Promise<{ isLoggedIn: boolean; hasValidToken: boolean; identity?: string }>;\n\n // Call Management\n\n /**\n * Initiate an outgoing call to a phone number or client.\n *\n * The user must be logged in before making a call. The call will be routed\n * through your Twilio backend configuration.\n *\n * @param options - Configuration object\n * @param options.to - Phone number (E.164 format) or Twilio client identifier to call\n * @returns Promise that resolves with success status and call SID\n * @returns success - Whether the call was initiated successfully\n * @returns callSid - Unique identifier for this call (if successful)\n *\n * @example\n * ```typescript\n * // Call a phone number\n * const result = await CapacitorTwilioVoice.makeCall({\n * to: '+1234567890'\n * });\n * console.log('Call SID:', result.callSid);\n *\n * // Call another Twilio client\n * await CapacitorTwilioVoice.makeCall({\n * to: 'client:alice'\n * });\n * ```\n */\n makeCall(options: { to: string }): Promise<{ success: boolean; callSid?: string }>;\n\n /**\n * Accept an incoming call.\n *\n * This should be called in response to a 'callInviteReceived' event.\n *\n * @param options - Configuration object\n * @param options.callSid - Unique identifier of the call to accept\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * CapacitorTwilioVoice.addListener('callInviteReceived', async (data) => {\n * console.log('Incoming call from:', data.from);\n * const result = await CapacitorTwilioVoice.acceptCall({\n * callSid: data.callSid\n * });\n * console.log('Call accepted:', result.success);\n * });\n * ```\n */\n acceptCall(options: { callSid: string }): Promise<{ success: boolean }>;\n\n /**\n * Reject an incoming call.\n *\n * This should be called in response to a 'callInviteReceived' event.\n * The caller will hear a busy signal or be directed to voicemail.\n *\n * @param options - Configuration object\n * @param options.callSid - Unique identifier of the call to reject\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * CapacitorTwilioVoice.addListener('callInviteReceived', async (data) => {\n * if (shouldRejectCall(data.from)) {\n * await CapacitorTwilioVoice.rejectCall({\n * callSid: data.callSid\n * });\n * }\n * });\n * ```\n */\n rejectCall(options: { callSid: string }): Promise<{ success: boolean }>;\n\n /**\n * End an active call.\n *\n * If callSid is not provided, this will end the currently active call.\n *\n * @param options - Configuration object\n * @param options.callSid - Unique identifier of the call to end (optional, defaults to current active call)\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * // End the current active call\n * await CapacitorTwilioVoice.endCall({});\n *\n * // End a specific call\n * await CapacitorTwilioVoice.endCall({\n * callSid: 'CA1234567890abcdef'\n * });\n * ```\n */\n endCall(options: { callSid?: string }): Promise<{ success: boolean }>;\n\n // Call Controls\n\n /**\n * Mute or unmute the microphone during an active call.\n *\n * When muted, the other party will not hear audio from your microphone.\n *\n * @param options - Configuration object\n * @param options.muted - Whether to mute (true) or unmute (false) the microphone\n * @param options.callSid - Unique identifier of the call (optional, defaults to current active call)\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * // Mute the microphone\n * await CapacitorTwilioVoice.muteCall({\n * muted: true\n * });\n *\n * // Unmute the microphone\n * await CapacitorTwilioVoice.muteCall({\n * muted: false\n * });\n * ```\n */\n muteCall(options: { muted: boolean; callSid?: string }): Promise<{ success: boolean }>;\n\n /**\n * Enable or disable speakerphone mode.\n *\n * When enabled, audio will be routed through the device's speaker instead of the earpiece.\n *\n * @param options - Configuration object\n * @param options.enabled - Whether to enable (true) or disable (false) speakerphone mode\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * // Enable speakerphone\n * await CapacitorTwilioVoice.setSpeaker({\n * enabled: true\n * });\n *\n * // Disable speakerphone\n * await CapacitorTwilioVoice.setSpeaker({\n * enabled: false\n * });\n * ```\n */\n setSpeaker(options: { enabled: boolean }): Promise<{ success: boolean }>;\n\n // Call Status\n\n /**\n * Get the current status of the active call.\n *\n * This provides real-time information about the call state, mute status,\n * hold status, and call identifiers.\n *\n * @returns Promise that resolves with call status information\n * @returns hasActiveCall - Whether there is currently an active call\n * @returns isOnHold - Whether the call is on hold\n * @returns isMuted - Whether the microphone is muted\n * @returns callSid - Unique identifier of the active call (if any)\n * @returns callState - Current state of the call (e.g., 'connecting', 'connected', 'ringing')\n *\n * @example\n * ```typescript\n * const status = await CapacitorTwilioVoice.getCallStatus();\n * if (status.hasActiveCall) {\n * console.log('Call SID:', status.callSid);\n * console.log('Call State:', status.callState);\n * console.log('Is Muted:', status.isMuted);\n * console.log('Is On Hold:', status.isOnHold);\n * }\n * ```\n */\n getCallStatus(): Promise<{\n hasActiveCall: boolean;\n isOnHold: boolean;\n isMuted: boolean;\n callSid?: string;\n callState?: string;\n }>;\n\n // Audio Permissions\n\n /**\n * Check if microphone permission has been granted.\n *\n * This does not request permission, only checks the current permission status.\n *\n * @returns Promise that resolves with permission status\n * @returns granted - Whether microphone permission has been granted\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.checkMicrophonePermission();\n * if (!result.granted) {\n * console.log('Microphone permission not granted');\n * }\n * ```\n */\n checkMicrophonePermission(): Promise<{ granted: boolean }>;\n\n /**\n * Request microphone permission from the user.\n *\n * On iOS and Android, this will show the system permission dialog if permission\n * has not been granted yet. If permission was previously denied, the user may need\n * to grant it in system settings.\n *\n * @returns Promise that resolves with permission status\n * @returns granted - Whether microphone permission was granted\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.requestMicrophonePermission();\n * if (result.granted) {\n * console.log('Microphone permission granted');\n * } else {\n * console.log('Microphone permission denied');\n * }\n * ```\n */\n requestMicrophonePermission(): Promise<{ granted: boolean }>;\n\n // Listeners for events\n\n /**\n * Listen for incoming call invitations.\n *\n * This event is fired when another user or phone number is calling you.\n * You should call acceptCall() or rejectCall() in response.\n *\n * @param eventName - The event name ('callInviteReceived')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the incoming call\n * @param listenerFunc.data.from - Phone number or client identifier of the caller\n * @param listenerFunc.data.to - Phone number or client identifier being called\n * @param listenerFunc.data.customParams - Custom parameters passed with the call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * const listener = await CapacitorTwilioVoice.addListener(\n * 'callInviteReceived',\n * (data) => {\n * console.log('Incoming call from:', data.from);\n * console.log('Call SID:', data.callSid);\n * console.log('Custom params:', data.customParams);\n * }\n * );\n *\n * // Remove listener when no longer needed\n * await listener.remove();\n * ```\n */\n addListener(\n eventName: 'callInviteReceived',\n listenerFunc: (data: { callSid: string; from: string; to: string; customParams: Record<string, string> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call connected events.\n *\n * This event is fired when a call (incoming or outgoing) has been successfully\n * connected and audio can be heard.\n *\n * @param eventName - The event name ('callConnected')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the connected call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callConnected', (data) => {\n * console.log('Call connected:', data.callSid);\n * // Start call timer, update UI, etc.\n * });\n * ```\n */\n addListener(\n eventName: 'callConnected',\n listenerFunc: (data: { callSid: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call invite cancellation events.\n *\n * This event is fired when an incoming call invitation is cancelled before being\n * answered, either by the caller hanging up or by the user declining.\n *\n * @param eventName - The event name ('callInviteCancelled')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the cancelled call\n * @param listenerFunc.data.reason - Reason for cancellation ('user_declined' or 'remote_cancelled')\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callInviteCancelled', (data) => {\n * if (data.reason === 'remote_cancelled') {\n * console.log('Caller hung up before you answered');\n * } else {\n * console.log('You declined the call');\n * }\n * });\n * ```\n */\n addListener(\n eventName: 'callInviteCancelled',\n listenerFunc: (data: { callSid: string; reason: 'user_declined' | 'remote_cancelled' }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for outgoing call initiation events.\n *\n * This event is fired when an outgoing call is initiated, either from the app\n * or from the system (e.g., CallKit on iOS, Telecom on Android).\n *\n * @param eventName - The event name ('outgoingCallInitiated')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the outgoing call\n * @param listenerFunc.data.to - Phone number or client identifier being called\n * @param listenerFunc.data.source - Source of the call ('app' or 'system')\n * @param listenerFunc.data.displayName - Display name for the recipient (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('outgoingCallInitiated', (data) => {\n * console.log('Calling:', data.to);\n * console.log('Call initiated from:', data.source);\n * // Update UI to show outgoing call screen\n * });\n * ```\n */\n addListener(\n eventName: 'outgoingCallInitiated',\n listenerFunc: (data: { callSid: string; to: string; source: 'app' | 'system'; displayName?: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for outgoing call failure events.\n *\n * This event is fired when an outgoing call fails to connect due to various reasons\n * such as missing credentials, permission issues, or network problems.\n *\n * @param eventName - The event name ('outgoingCallFailed')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the failed call\n * @param listenerFunc.data.to - Phone number or client identifier that was being called\n * @param listenerFunc.data.reason - Reason for the failure\n * @param listenerFunc.data.displayName - Display name for the recipient (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('outgoingCallFailed', (data) => {\n * console.error('Call to', data.to, 'failed:', data.reason);\n *\n * switch (data.reason) {\n * case 'missing_access_token':\n * // User needs to login\n * break;\n * case 'microphone_permission_denied':\n * // Request microphone permission\n * break;\n * case 'connection_failed':\n * // Network issue, retry later\n * break;\n * }\n * });\n * ```\n */\n addListener(\n eventName: 'outgoingCallFailed',\n listenerFunc: (data: {\n callSid: string;\n to: string;\n reason:\n | 'missing_access_token'\n | 'connection_failed'\n | 'no_call_details'\n | 'microphone_permission_denied'\n | 'invalid_contact'\n | 'callkit_request_failed'\n | 'unsupported_intent';\n displayName?: string;\n }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call disconnection events.\n *\n * This event is fired when a call ends, either normally or due to an error.\n *\n * @param eventName - The event name ('callDisconnected')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the disconnected call\n * @param listenerFunc.data.error - Error message if the call was disconnected due to an error (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callDisconnected', (data) => {\n * console.log('Call ended:', data.callSid);\n * if (data.error) {\n * console.error('Call ended with error:', data.error);\n * }\n * // Update UI, stop call timer, etc.\n * });\n * ```\n */\n addListener(\n eventName: 'callDisconnected',\n listenerFunc: (data: { callSid: string; error?: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call ringing events.\n *\n * This event is fired when an outgoing call starts ringing on the other end.\n *\n * @param eventName - The event name ('callRinging')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the ringing call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callRinging', (data) => {\n * console.log('Call is ringing:', data.callSid);\n * // Play ringing sound, update UI, etc.\n * });\n * ```\n */\n addListener(\n eventName: 'callRinging',\n listenerFunc: (data: { callSid: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call reconnecting events.\n *\n * This event is fired when a call loses connection and Twilio is attempting to\n * reconnect. The call is not disconnected yet but audio may be interrupted.\n *\n * @param eventName - The event name ('callReconnecting')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the reconnecting call\n * @param listenerFunc.data.error - Error message describing the connection issue (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callReconnecting', (data) => {\n * console.log('Call reconnecting:', data.callSid);\n * if (data.error) {\n * console.log('Reconnection reason:', data.error);\n * }\n * // Show reconnecting indicator in UI\n * });\n * ```\n */\n addListener(\n eventName: 'callReconnecting',\n listenerFunc: (data: { callSid: string; error?: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call reconnected events.\n *\n * This event is fired when a call successfully reconnects after a connection loss.\n * Audio should resume normally after this event.\n *\n * @param eventName - The event name ('callReconnected')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the reconnected call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callReconnected', (data) => {\n * console.log('Call reconnected:', data.callSid);\n * // Hide reconnecting indicator, resume normal UI\n * });\n * ```\n */\n addListener(\n eventName: 'callReconnected',\n listenerFunc: (data: { callSid: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call quality warning events.\n *\n * This event is fired when the call quality changes, providing warnings about\n * potential issues like high jitter, packet loss, or low audio levels.\n *\n * @param eventName - The event name ('callQualityWarningsChanged')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the call\n * @param listenerFunc.data.currentWarnings - Array of current quality warnings\n * @param listenerFunc.data.previousWarnings - Array of previous quality warnings\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callQualityWarningsChanged', (data) => {\n * console.log('Call quality warnings:', data.currentWarnings);\n *\n * if (data.currentWarnings.includes('high-jitter')) {\n * console.warn('Network jitter detected');\n * }\n * if (data.currentWarnings.includes('high-packet-loss')) {\n * console.warn('Packet loss detected');\n * }\n * });\n * ```\n */\n addListener(\n eventName: 'callQualityWarningsChanged',\n listenerFunc: (data: { callSid: string; currentWarnings: string[]; previousWarnings: string[] }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for successful registration events.\n *\n * This event is fired when the device successfully registers with Twilio Voice\n * and is ready to make and receive calls. This typically occurs after a successful\n * login with a valid access token.\n *\n * @param eventName - The event name ('registrationSuccess')\n * @param listenerFunc - Callback function to handle the event\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('registrationSuccess', () => {\n * console.log('Successfully registered with Twilio Voice');\n * // Update UI to show ready state\n * });\n * ```\n */\n addListener(eventName: 'registrationSuccess', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for registration failure events.\n *\n * This event is fired when the device fails to register with Twilio Voice,\n * typically due to an invalid or expired access token, network issues, or\n * Twilio service problems.\n *\n * @param eventName - The event name ('registrationFailure')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.error - Error message describing the registration failure\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('registrationFailure', (data) => {\n * console.error('Registration failed:', data.error);\n * // Re-authenticate user or show error message\n * });\n * ```\n */\n addListener(\n eventName: 'registrationFailure',\n listenerFunc: (data: { error: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all registered event listeners.\n *\n * This is useful for cleanup when your component unmounts or when you want to\n * reset all event handling.\n *\n * @returns Promise that resolves when all listeners have been removed\n *\n * @example\n * ```typescript\n * // In a React component cleanup\n * useEffect(() => {\n * // Setup listeners...\n *\n * return () => {\n * CapacitorTwilioVoice.removeAllListeners();\n * };\n * }, []);\n * ```\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ version: string }>} a Promise with version for this plugin\n * @throws An error if something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n\n/**\n * Handle returned by event listener registration.\n *\n * This interface provides a method to remove the registered event listener\n * when it's no longer needed.\n *\n * @example\n * ```typescript\n * const handle = await CapacitorTwilioVoice.addListener('callConnected', (data) => {\n * console.log('Call connected:', data.callSid);\n * });\n *\n * // Later, remove the listener\n * await handle.remove();\n * ```\n */\nexport interface PluginListenerHandle {\n /**\n * Remove the registered event listener.\n *\n * After calling this method, the listener callback will no longer be invoked\n * when the event occurs.\n *\n * @returns Promise that resolves when the listener has been removed\n *\n * @example\n * ```typescript\n * const listener = await CapacitorTwilioVoice.addListener('callInviteReceived', handleIncomingCall);\n * // Remove listener when component unmounts or when no longer needed\n * await listener.remove();\n * ```\n */\n remove(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Capacitor plugin for integrating Twilio Voice functionality into mobile applications.\n *\n * This plugin provides comprehensive voice call capabilities including:\n * - User authentication with Twilio access tokens\n * - Making and receiving phone calls\n * - Call management (accept, reject, end, mute)\n * - Audio routing controls (speaker mode)\n * - Real-time call status monitoring\n * - Event-driven architecture for call lifecycle events\n * - Microphone permission handling\n *\n * @example\n * ```typescript\n * import { CapacitorTwilioVoice } from 'capacitor-twilio-voice';\n *\n * // Login with access token\n * await CapacitorTwilioVoice.login({ accessToken: 'your-twilio-token' });\n *\n * // Make a call\n * await CapacitorTwilioVoice.makeCall({ to: '+1234567890' });\n *\n * // Listen for incoming calls\n * CapacitorTwilioVoice.addListener('callInviteReceived', (data) => {\n * console.log('Incoming call from:', data.from);\n * });\n * ```\n */\nexport interface CapacitorTwilioVoicePlugin {\n // Authentication\n\n /**\n * Authenticate the user with Twilio Voice using an access token.\n *\n * The access token should be generated on your backend server using your Twilio credentials.\n * This token is required to make and receive calls through Twilio Voice.\n *\n * @param options - Configuration object\n * @param options.accessToken - Twilio access token obtained from your backend server\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.login({\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'\n * });\n * console.log('Login successful:', result.success);\n * ```\n */\n login(options: { accessToken: string }): Promise<{ success: boolean }>;\n\n /**\n * Log out the current user and unregister from Twilio Voice.\n *\n * This will disconnect any active calls and stop the device from receiving\n * new incoming call notifications.\n *\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.logout();\n * console.log('Logout successful:', result.success);\n * ```\n */\n logout(): Promise<{ success: boolean }>;\n\n /**\n * Check if the user is currently logged in and has a valid access token.\n *\n * @returns Promise that resolves with login status information\n * @returns isLoggedIn - Whether the user is currently logged in\n * @returns hasValidToken - Whether the access token is still valid\n * @returns identity - The user's Twilio identity (if logged in)\n *\n * @example\n * ```typescript\n * const status = await CapacitorTwilioVoice.isLoggedIn();\n * if (status.isLoggedIn && status.hasValidToken) {\n * console.log('User identity:', status.identity);\n * } else {\n * // Re-authenticate the user\n * }\n * ```\n */\n isLoggedIn(): Promise<{ isLoggedIn: boolean; hasValidToken: boolean; identity?: string }>;\n\n // Call Management\n\n /**\n * Initiate an outgoing call to a phone number or client.\n *\n * The user must be logged in before making a call. The call will be routed\n * through your Twilio backend configuration.\n *\n * @param options - Configuration object\n * @param options.to - Phone number (E.164 format) or Twilio client identifier to call\n * @returns Promise that resolves with success status and call SID\n * @returns success - Whether the call was initiated successfully\n * @returns callSid - Unique identifier for this call (if successful)\n *\n * @example\n * ```typescript\n * // Call a phone number\n * const result = await CapacitorTwilioVoice.makeCall({\n * to: '+1234567890'\n * });\n * console.log('Call SID:', result.callSid);\n *\n * // Call another Twilio client\n * await CapacitorTwilioVoice.makeCall({\n * to: 'client:alice'\n * });\n * ```\n */\n makeCall(options: { to: string }): Promise<{ success: boolean; callSid?: string }>;\n\n /**\n * Accept an incoming call.\n *\n * This should be called in response to a 'callInviteReceived' event.\n *\n * @param options - Configuration object\n * @param options.callSid - Unique identifier of the call to accept\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * CapacitorTwilioVoice.addListener('callInviteReceived', async (data) => {\n * console.log('Incoming call from:', data.from);\n * const result = await CapacitorTwilioVoice.acceptCall({\n * callSid: data.callSid\n * });\n * console.log('Call accepted:', result.success);\n * });\n * ```\n */\n acceptCall(options: { callSid: string }): Promise<{ success: boolean }>;\n\n /**\n * Reject an incoming call.\n *\n * This should be called in response to a 'callInviteReceived' event.\n * The caller will hear a busy signal or be directed to voicemail.\n *\n * @param options - Configuration object\n * @param options.callSid - Unique identifier of the call to reject\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * CapacitorTwilioVoice.addListener('callInviteReceived', async (data) => {\n * if (shouldRejectCall(data.from)) {\n * await CapacitorTwilioVoice.rejectCall({\n * callSid: data.callSid\n * });\n * }\n * });\n * ```\n */\n rejectCall(options: { callSid: string }): Promise<{ success: boolean }>;\n\n /**\n * End an active call.\n *\n * If callSid is not provided, this will end the currently active call.\n *\n * @param options - Configuration object\n * @param options.callSid - Unique identifier of the call to end (optional, defaults to current active call)\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * // End the current active call\n * await CapacitorTwilioVoice.endCall({});\n *\n * // End a specific call\n * await CapacitorTwilioVoice.endCall({\n * callSid: 'CA1234567890abcdef'\n * });\n * ```\n */\n endCall(options: { callSid?: string }): Promise<{ success: boolean }>;\n\n // Call Controls\n\n /**\n * Mute or unmute the microphone during an active call.\n *\n * When muted, the other party will not hear audio from your microphone.\n *\n * @param options - Configuration object\n * @param options.muted - Whether to mute (true) or unmute (false) the microphone\n * @param options.callSid - Unique identifier of the call (optional, defaults to current active call)\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * // Mute the microphone\n * await CapacitorTwilioVoice.muteCall({\n * muted: true\n * });\n *\n * // Unmute the microphone\n * await CapacitorTwilioVoice.muteCall({\n * muted: false\n * });\n * ```\n */\n muteCall(options: { muted: boolean; callSid?: string }): Promise<{ success: boolean }>;\n\n /**\n * Enable or disable speakerphone mode.\n *\n * When enabled, audio will be routed through the device's speaker instead of the earpiece.\n *\n * @param options - Configuration object\n * @param options.enabled - Whether to enable (true) or disable (false) speakerphone mode\n * @returns Promise that resolves with success status\n *\n * @example\n * ```typescript\n * // Enable speakerphone\n * await CapacitorTwilioVoice.setSpeaker({\n * enabled: true\n * });\n *\n * // Disable speakerphone\n * await CapacitorTwilioVoice.setSpeaker({\n * enabled: false\n * });\n * ```\n */\n setSpeaker(options: { enabled: boolean }): Promise<{ success: boolean }>;\n\n // Call Status\n\n /**\n * Get the current status of the active call.\n *\n * This provides real-time information about the call state, mute status,\n * hold status, and call identifiers.\n *\n * @returns Promise that resolves with call status information\n * @returns hasActiveCall - Whether there is currently an active call\n * @returns isOnHold - Whether the call is on hold\n * @returns isMuted - Whether the microphone is muted\n * @returns callSid - Unique identifier of the active call (if any)\n * @returns callState - Current state of the call (e.g., 'connecting', 'connected', 'ringing')\n * @returns pendingInvites - Number of pending incoming call invitations\n * @returns activeCallsCount - Total number of active calls being tracked\n *\n * @example\n * ```typescript\n * const status = await CapacitorTwilioVoice.getCallStatus();\n * if (status.hasActiveCall) {\n * console.log('Call SID:', status.callSid);\n * console.log('Call State:', status.callState);\n * console.log('Is Muted:', status.isMuted);\n * console.log('Is On Hold:', status.isOnHold);\n * }\n * ```\n */\n getCallStatus(): Promise<{\n /** Whether there is currently an active call */\n hasActiveCall: boolean;\n /** Whether the active call is on hold */\n isOnHold: boolean;\n /** Whether the active call is muted */\n isMuted: boolean;\n /** The unique identifier (SID) for the active call */\n callSid?: string;\n /** Current state: 'idle', 'connecting', 'ringing', 'connected', 'reconnecting', 'disconnected', or 'unknown' */\n callState?: string;\n /** Number of pending incoming call invitations */\n pendingInvites: number;\n /** Total number of active calls being tracked */\n activeCallsCount: number;\n }>;\n\n // Audio Permissions\n\n /**\n * Check if microphone permission has been granted.\n *\n * This does not request permission, only checks the current permission status.\n *\n * @returns Promise that resolves with permission status\n * @returns granted - Whether microphone permission has been granted\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.checkMicrophonePermission();\n * if (!result.granted) {\n * console.log('Microphone permission not granted');\n * }\n * ```\n */\n checkMicrophonePermission(): Promise<{ granted: boolean }>;\n\n /**\n * Request microphone permission from the user.\n *\n * On iOS and Android, this will show the system permission dialog if permission\n * has not been granted yet. If permission was previously denied, the user may need\n * to grant it in system settings.\n *\n * @returns Promise that resolves with permission status\n * @returns granted - Whether microphone permission was granted\n *\n * @example\n * ```typescript\n * const result = await CapacitorTwilioVoice.requestMicrophonePermission();\n * if (result.granted) {\n * console.log('Microphone permission granted');\n * } else {\n * console.log('Microphone permission denied');\n * }\n * ```\n */\n requestMicrophonePermission(): Promise<{ granted: boolean }>;\n\n // Listeners for events\n\n /**\n * Listen for incoming call invitations.\n *\n * This event is fired when another user or phone number is calling you.\n * You should call acceptCall() or rejectCall() in response.\n *\n * @param eventName - The event name ('callInviteReceived')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the incoming call\n * @param listenerFunc.data.from - Phone number or client identifier of the caller\n * @param listenerFunc.data.to - Phone number or client identifier being called\n * @param listenerFunc.data.customParams - Custom parameters passed with the call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * const listener = await CapacitorTwilioVoice.addListener(\n * 'callInviteReceived',\n * (data) => {\n * console.log('Incoming call from:', data.from);\n * console.log('Call SID:', data.callSid);\n * console.log('Custom params:', data.customParams);\n * }\n * );\n *\n * // Remove listener when no longer needed\n * await listener.remove();\n * ```\n */\n addListener(\n eventName: 'callInviteReceived',\n listenerFunc: (data: { callSid: string; from: string; to: string; customParams: Record<string, string> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call connected events.\n *\n * This event is fired when a call (incoming or outgoing) has been successfully\n * connected and audio can be heard.\n *\n * @param eventName - The event name ('callConnected')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the connected call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callConnected', (data) => {\n * console.log('Call connected:', data.callSid);\n * // Start call timer, update UI, etc.\n * });\n * ```\n */\n addListener(\n eventName: 'callConnected',\n listenerFunc: (data: { callSid: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call invite cancellation events.\n *\n * This event is fired when an incoming call invitation is cancelled before being\n * answered, either by the caller hanging up or by the user declining.\n *\n * @param eventName - The event name ('callInviteCancelled')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the cancelled call\n * @param listenerFunc.data.reason - Reason for cancellation ('user_declined' or 'remote_cancelled')\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callInviteCancelled', (data) => {\n * if (data.reason === 'remote_cancelled') {\n * console.log('Caller hung up before you answered');\n * } else {\n * console.log('You declined the call');\n * }\n * });\n * ```\n */\n addListener(\n eventName: 'callInviteCancelled',\n listenerFunc: (data: { callSid: string; reason: 'user_declined' | 'remote_cancelled' }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for outgoing call initiation events.\n *\n * This event is fired when an outgoing call is initiated, either from the app\n * or from the system (e.g., CallKit on iOS, Telecom on Android).\n *\n * @param eventName - The event name ('outgoingCallInitiated')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the outgoing call\n * @param listenerFunc.data.to - Phone number or client identifier being called\n * @param listenerFunc.data.source - Source of the call ('app' or 'system')\n * @param listenerFunc.data.displayName - Display name for the recipient (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('outgoingCallInitiated', (data) => {\n * console.log('Calling:', data.to);\n * console.log('Call initiated from:', data.source);\n * // Update UI to show outgoing call screen\n * });\n * ```\n */\n addListener(\n eventName: 'outgoingCallInitiated',\n listenerFunc: (data: { callSid: string; to: string; source: 'app' | 'system'; displayName?: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for outgoing call failure events.\n *\n * This event is fired when an outgoing call fails to connect due to various reasons\n * such as missing credentials, permission issues, or network problems.\n *\n * @param eventName - The event name ('outgoingCallFailed')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the failed call\n * @param listenerFunc.data.to - Phone number or client identifier that was being called\n * @param listenerFunc.data.reason - Reason for the failure\n * @param listenerFunc.data.displayName - Display name for the recipient (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('outgoingCallFailed', (data) => {\n * console.error('Call to', data.to, 'failed:', data.reason);\n *\n * switch (data.reason) {\n * case 'missing_access_token':\n * // User needs to login\n * break;\n * case 'microphone_permission_denied':\n * // Request microphone permission\n * break;\n * case 'connection_failed':\n * // Network issue, retry later\n * break;\n * }\n * });\n * ```\n */\n addListener(\n eventName: 'outgoingCallFailed',\n listenerFunc: (data: {\n callSid: string;\n to: string;\n reason:\n | 'missing_access_token'\n | 'connection_failed'\n | 'no_call_details'\n | 'microphone_permission_denied'\n | 'invalid_contact'\n | 'callkit_request_failed'\n | 'unsupported_intent';\n displayName?: string;\n }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call disconnection events.\n *\n * This event is fired when a call ends, either normally or due to an error.\n *\n * @param eventName - The event name ('callDisconnected')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the disconnected call\n * @param listenerFunc.data.error - Error message if the call was disconnected due to an error (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callDisconnected', (data) => {\n * console.log('Call ended:', data.callSid);\n * if (data.error) {\n * console.error('Call ended with error:', data.error);\n * }\n * // Update UI, stop call timer, etc.\n * });\n * ```\n */\n addListener(\n eventName: 'callDisconnected',\n listenerFunc: (data: { callSid: string; error?: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call ringing events.\n *\n * This event is fired when an outgoing call starts ringing on the other end.\n *\n * @param eventName - The event name ('callRinging')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the ringing call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callRinging', (data) => {\n * console.log('Call is ringing:', data.callSid);\n * // Play ringing sound, update UI, etc.\n * });\n * ```\n */\n addListener(\n eventName: 'callRinging',\n listenerFunc: (data: { callSid: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call reconnecting events.\n *\n * This event is fired when a call loses connection and Twilio is attempting to\n * reconnect. The call is not disconnected yet but audio may be interrupted.\n *\n * @param eventName - The event name ('callReconnecting')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the reconnecting call\n * @param listenerFunc.data.error - Error message describing the connection issue (optional)\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callReconnecting', (data) => {\n * console.log('Call reconnecting:', data.callSid);\n * if (data.error) {\n * console.log('Reconnection reason:', data.error);\n * }\n * // Show reconnecting indicator in UI\n * });\n * ```\n */\n addListener(\n eventName: 'callReconnecting',\n listenerFunc: (data: { callSid: string; error?: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call reconnected events.\n *\n * This event is fired when a call successfully reconnects after a connection loss.\n * Audio should resume normally after this event.\n *\n * @param eventName - The event name ('callReconnected')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the reconnected call\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callReconnected', (data) => {\n * console.log('Call reconnected:', data.callSid);\n * // Hide reconnecting indicator, resume normal UI\n * });\n * ```\n */\n addListener(\n eventName: 'callReconnected',\n listenerFunc: (data: { callSid: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for call quality warning events.\n *\n * This event is fired when the call quality changes, providing warnings about\n * potential issues like high jitter, packet loss, or low audio levels.\n *\n * @param eventName - The event name ('callQualityWarningsChanged')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.callSid - Unique identifier for the call\n * @param listenerFunc.data.currentWarnings - Array of current quality warnings\n * @param listenerFunc.data.previousWarnings - Array of previous quality warnings\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('callQualityWarningsChanged', (data) => {\n * console.log('Call quality warnings:', data.currentWarnings);\n *\n * if (data.currentWarnings.includes('high-jitter')) {\n * console.warn('Network jitter detected');\n * }\n * if (data.currentWarnings.includes('high-packet-loss')) {\n * console.warn('Packet loss detected');\n * }\n * });\n * ```\n */\n addListener(\n eventName: 'callQualityWarningsChanged',\n listenerFunc: (data: { callSid: string; currentWarnings: string[]; previousWarnings: string[] }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for successful registration events.\n *\n * This event is fired when the device successfully registers with Twilio Voice\n * and is ready to make and receive calls. This typically occurs after a successful\n * login with a valid access token.\n *\n * @param eventName - The event name ('registrationSuccess')\n * @param listenerFunc - Callback function to handle the event\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('registrationSuccess', () => {\n * console.log('Successfully registered with Twilio Voice');\n * // Update UI to show ready state\n * });\n * ```\n */\n addListener(eventName: 'registrationSuccess', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for registration failure events.\n *\n * This event is fired when the device fails to register with Twilio Voice,\n * typically due to an invalid or expired access token, network issues, or\n * Twilio service problems.\n *\n * @param eventName - The event name ('registrationFailure')\n * @param listenerFunc - Callback function to handle the event\n * @param listenerFunc.data - Event data\n * @param listenerFunc.data.error - Error message describing the registration failure\n * @returns Promise that resolves with a listener handle for removing the listener\n *\n * @example\n * ```typescript\n * await CapacitorTwilioVoice.addListener('registrationFailure', (data) => {\n * console.error('Registration failed:', data.error);\n * // Re-authenticate user or show error message\n * });\n * ```\n */\n addListener(\n eventName: 'registrationFailure',\n listenerFunc: (data: { error: string }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all registered event listeners.\n *\n * This is useful for cleanup when your component unmounts or when you want to\n * reset all event handling.\n *\n * @returns Promise that resolves when all listeners have been removed\n *\n * @example\n * ```typescript\n * // In a React component cleanup\n * useEffect(() => {\n * // Setup listeners...\n *\n * return () => {\n * CapacitorTwilioVoice.removeAllListeners();\n * };\n * }, []);\n * ```\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ version: string }>} a Promise with version for this plugin\n * @throws An error if something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n\n/**\n * Handle returned by event listener registration.\n *\n * This interface provides a method to remove the registered event listener\n * when it's no longer needed.\n *\n * @example\n * ```typescript\n * const handle = await CapacitorTwilioVoice.addListener('callConnected', (data) => {\n * console.log('Call connected:', data.callSid);\n * });\n *\n * // Later, remove the listener\n * await handle.remove();\n * ```\n */\nexport interface PluginListenerHandle {\n /**\n * Remove the registered event listener.\n *\n * After calling this method, the listener callback will no longer be invoked\n * when the event occurs.\n *\n * @returns Promise that resolves when the listener has been removed\n *\n * @example\n * ```typescript\n * const listener = await CapacitorTwilioVoice.addListener('callInviteReceived', handleIncomingCall);\n * // Remove listener when component unmounts or when no longer needed\n * await listener.remove();\n * ```\n */\n remove(): Promise<void>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export declare class CapacitorTwilioVoiceWeb extends WebPlugin implements Capaci
|
|
|
52
52
|
isMuted: boolean;
|
|
53
53
|
callSid?: string;
|
|
54
54
|
callState?: string;
|
|
55
|
+
pendingInvites: number;
|
|
56
|
+
activeCallsCount: number;
|
|
55
57
|
}>;
|
|
56
58
|
checkMicrophonePermission(): Promise<{
|
|
57
59
|
granted: boolean;
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACpD,iBAAiB;IACjB,KAAK,CAAC,KAAK,CAAC,QAAiC;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,QAAQ,CAAC,QAAwB;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA6B;QAC5C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA6B;QAC5C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAA8B;QAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,QAAQ,CAAC,QAA8C;QAC3D,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA8B;QAC7C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACd,KAAK,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IACpD,iBAAiB;IACjB,KAAK,CAAC,KAAK,CAAC,QAAiC;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,kBAAkB;IAClB,KAAK,CAAC,QAAQ,CAAC,QAAwB;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA6B;QAC5C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA6B;QAC5C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAA8B;QAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,QAAQ,CAAC,QAA8C;QAC3D,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA8B;QAC7C,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACd,KAAK,CAAC,aAAa;QASjB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,oBAAoB;IACpB,KAAK,CAAC,yBAAyB;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,2BAA2B;QAC/B,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorTwilioVoicePlugin } from './definitions';\n\nexport class CapacitorTwilioVoiceWeb extends WebPlugin implements CapacitorTwilioVoicePlugin {\n // Authentication\n async login(_options: { accessToken: string }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async logout(): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async isLoggedIn(): Promise<{ isLoggedIn: boolean; hasValidToken: boolean; identity?: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n // Call Management\n async makeCall(_options: { to: string }): Promise<{ success: boolean; callSid?: string }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async acceptCall(_options: { callSid: string }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async rejectCall(_options: { callSid: string }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async endCall(_options: { callSid?: string }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n // Call Controls\n async muteCall(_options: { muted: boolean; callSid?: string }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async setSpeaker(_options: { enabled: boolean }): Promise<{ success: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n // Call Status\n async getCallStatus(): Promise<{\n hasActiveCall: boolean;\n isOnHold: boolean;\n isMuted: boolean;\n callSid?: string;\n callState?: string;\n pendingInvites: number;\n activeCallsCount: number;\n }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n // Audio Permissions\n async checkMicrophonePermission(): Promise<{ granted: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async requestMicrophonePermission(): Promise<{ granted: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
|
@@ -27,7 +27,7 @@ public protocol PushKitEventDelegate: AnyObject {
|
|
|
27
27
|
*/
|
|
28
28
|
@objc(CapacitorTwilioVoicePlugin)
|
|
29
29
|
public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEventDelegate {
|
|
30
|
-
private let PLUGIN_VERSION: String = "7.6.
|
|
30
|
+
private let PLUGIN_VERSION: String = "7.6.4"
|
|
31
31
|
|
|
32
32
|
public let identifier = "CapacitorTwilioVoicePlugin"
|
|
33
33
|
public let jsName = "CapacitorTwilioVoice"
|