@capgo/capacitor-twilio-voice 8.0.32 → 8.1.0

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 CHANGED
@@ -633,7 +633,7 @@ Check if the user is currently logged in and has a valid access token.
633
633
  ### makeCall(...)
634
634
 
635
635
  ```typescript
636
- makeCall(options: { to: string; }) => Promise<{ success: boolean; callSid?: string; }>
636
+ makeCall(options: { to: string; displayName?: string; }) => Promise<{ success: boolean; callSid?: string; }>
637
637
  ```
638
638
 
639
639
  Initiate an outgoing call to a phone number or client.
@@ -641,9 +641,9 @@ Initiate an outgoing call to a phone number or client.
641
641
  The user must be logged in before making a call. The call will be routed
642
642
  through your Twilio backend configuration.
643
643
 
644
- | Param | Type | Description |
645
- | ------------- | ---------------------------- | ---------------------- |
646
- | **`options`** | <code>{ to: string; }</code> | - Configuration object |
644
+ | Param | Type | Description |
645
+ | ------------- | -------------------------------------------------- | ---------------------- |
646
+ | **`options`** | <code>{ to: string; displayName?: string; }</code> | - Configuration object |
647
647
 
648
648
  **Returns:** <code>Promise&lt;{ success: boolean; callSid?: string; }&gt;</code>
649
649
 
@@ -75,7 +75,7 @@ import org.json.JSONObject;
75
75
  )
76
76
  public class CapacitorTwilioVoicePlugin extends Plugin {
77
77
 
78
- private final String pluginVersion = "8.0.32";
78
+ private final String pluginVersion = "8.1.0";
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
@@ -90,12 +90,12 @@
90
90
  },
91
91
  {
92
92
  "name": "makeCall",
93
- "signature": "(options: { to: string; }) => Promise<{ success: boolean; callSid?: string; }>",
93
+ "signature": "(options: { to: string; displayName?: string; }) => Promise<{ success: boolean; callSid?: string; }>",
94
94
  "parameters": [
95
95
  {
96
96
  "name": "options",
97
97
  "docs": "- Configuration object",
98
- "type": "{ to: string; }"
98
+ "type": "{ to: string; displayName?: string | undefined; }"
99
99
  }
100
100
  ],
101
101
  "returns": "Promise<{ success: boolean; callSid?: string | undefined; }>",
@@ -108,6 +108,10 @@
108
108
  "name": "param",
109
109
  "text": "options.to - Phone number (E.164 format) or Twilio client identifier to call"
110
110
  },
111
+ {
112
+ "name": "param",
113
+ "text": "options.displayName - Optional human-readable name used as the\niOS CXHandle value so Phone.app Recents renders a readable label\ninstead of the raw `to` identity."
114
+ },
111
115
  {
112
116
  "name": "returns",
113
117
  "text": "Promise that resolves with success status and call SID"
@@ -122,7 +126,7 @@
122
126
  },
123
127
  {
124
128
  "name": "example",
125
- "text": "```typescript\n// Call a phone number\nconst result = await CapacitorTwilioVoice.makeCall({\n to: '+1234567890'\n});\nconsole.log('Call SID:', result.callSid);\n\n// Call another Twilio client\nawait CapacitorTwilioVoice.makeCall({\n to: 'client:alice'\n});\n```"
129
+ "text": "```typescript\n// Call a phone number\nconst result = await CapacitorTwilioVoice.makeCall({\n to: '+1234567890'\n});\nconsole.log('Call SID:', result.callSid);\n\n// Call another Twilio client with a readable name for CallKit Recents\nawait CapacitorTwilioVoice.makeCall({\n to: 'client:alice',\n displayName: 'Alice Smith'\n});\n```"
126
130
  }
127
131
  ],
128
132
  "docs": "Initiate an outgoing call to a phone number or client.\n\nThe user must be logged in before making a call. The call will be routed\nthrough your Twilio backend configuration.",
@@ -130,6 +130,9 @@ export interface CapacitorTwilioVoicePlugin {
130
130
  *
131
131
  * @param options - Configuration object
132
132
  * @param options.to - Phone number (E.164 format) or Twilio client identifier to call
133
+ * @param options.displayName - Optional human-readable name used as the
134
+ * iOS CXHandle value so Phone.app Recents renders a readable label
135
+ * instead of the raw `to` identity.
133
136
  * @returns Promise that resolves with success status and call SID
134
137
  * @returns success - Whether the call was initiated successfully
135
138
  * @returns callSid - Unique identifier for this call (if successful)
@@ -142,14 +145,16 @@ export interface CapacitorTwilioVoicePlugin {
142
145
  * });
143
146
  * console.log('Call SID:', result.callSid);
144
147
  *
145
- * // Call another Twilio client
148
+ * // Call another Twilio client with a readable name for CallKit Recents
146
149
  * await CapacitorTwilioVoice.makeCall({
147
- * to: 'client:alice'
150
+ * to: 'client:alice',
151
+ * displayName: 'Alice Smith'
148
152
  * });
149
153
  * ```
150
154
  */
151
155
  makeCall(options: {
152
156
  to: string;
157
+ displayName?: string;
153
158
  }): Promise<{
154
159
  success: boolean;
155
160
  callSid?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG","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 */\n\n/**\n * Represents a pending incoming call invitation.\n *\n * This interface describes the data structure for call invitations that have been received\n * but not yet accepted or rejected. The same structure is used both in the\n * `callInviteReceived` event and in the `pendingInvites` array returned by `getCallStatus()`.\n *\n * @example\n * ```typescript\n * CapacitorTwilioVoice.addListener('callInviteReceived', (data: CallInvite) => {\n * console.log('Incoming call from:', data.from);\n * console.log('Call SID:', data.callSid);\n * console.log('To:', data.to);\n * console.log('Custom params:', data.customParams);\n * });\n *\n * const status = await CapacitorTwilioVoice.getCallStatus();\n * status.pendingInvites.forEach((invite: CallInvite) => {\n * console.log('Pending call from:', invite.from);\n * });\n * ```\n */\nexport interface CallInvite {\n /** Unique identifier for the incoming call invitation */\n callSid: string;\n /** Phone number or client identifier of the caller (may include custom caller name) */\n from: string;\n /** Phone number or client identifier being called */\n to: string;\n /** Custom parameters passed with the call invitation */\n customParams: Record<string, string>;\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 - Array of pending incoming call invitations with the same data as callInviteReceived\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 /** Array of pending incoming call invitations */\n pendingInvites: CallInvite[];\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 of type {@link CallInvite}\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(eventName: 'callInviteReceived', listenerFunc: (data: CallInvite) => void): 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":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG","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 */\n\n/**\n * Represents a pending incoming call invitation.\n *\n * This interface describes the data structure for call invitations that have been received\n * but not yet accepted or rejected. The same structure is used both in the\n * `callInviteReceived` event and in the `pendingInvites` array returned by `getCallStatus()`.\n *\n * @example\n * ```typescript\n * CapacitorTwilioVoice.addListener('callInviteReceived', (data: CallInvite) => {\n * console.log('Incoming call from:', data.from);\n * console.log('Call SID:', data.callSid);\n * console.log('To:', data.to);\n * console.log('Custom params:', data.customParams);\n * });\n *\n * const status = await CapacitorTwilioVoice.getCallStatus();\n * status.pendingInvites.forEach((invite: CallInvite) => {\n * console.log('Pending call from:', invite.from);\n * });\n * ```\n */\nexport interface CallInvite {\n /** Unique identifier for the incoming call invitation */\n callSid: string;\n /** Phone number or client identifier of the caller (may include custom caller name) */\n from: string;\n /** Phone number or client identifier being called */\n to: string;\n /** Custom parameters passed with the call invitation */\n customParams: Record<string, string>;\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 * @param options.displayName - Optional human-readable name used as the\n * iOS CXHandle value so Phone.app Recents renders a readable label\n * instead of the raw `to` identity.\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 with a readable name for CallKit Recents\n * await CapacitorTwilioVoice.makeCall({\n * to: 'client:alice',\n * displayName: 'Alice Smith'\n * });\n * ```\n */\n makeCall(options: { to: string; displayName?: 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 - Array of pending incoming call invitations with the same data as callInviteReceived\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 /** Array of pending incoming call invitations */\n pendingInvites: CallInvite[];\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 of type {@link CallInvite}\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(eventName: 'callInviteReceived', listenerFunc: (data: CallInvite) => void): 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"]}
@@ -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 pluginVersion: String = "8.0.32"
30
+ private let pluginVersion: String = "8.1.0"
31
31
 
32
32
  public let identifier = "CapacitorTwilioVoicePlugin"
33
33
  public let jsName = "CapacitorTwilioVoice"
@@ -377,6 +377,8 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
377
377
  return
378
378
  }
379
379
 
380
+ let displayName = call.getString("displayName")
381
+
380
382
  checkRecordPermission { [weak self] permissionGranted in
381
383
  guard permissionGranted else {
382
384
  call.reject("Microphone permission not granted")
@@ -388,6 +390,7 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
388
390
  handle: to,
389
391
  to: to,
390
392
  isSystemInitiated: false,
393
+ displayName: displayName,
391
394
  completion: { success in
392
395
  if success {
393
396
  call.resolve(["success": true, "callSid": uuid.uuidString])
@@ -841,7 +844,8 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
841
844
  isSystemInitiated: isSystemInitiated,
842
845
  displayName: displayName)
843
846
 
844
- let callHandle = CXHandle(type: .generic, value: handle)
847
+ let handleValue = (displayName?.isEmpty == false ? displayName! : handle)
848
+ let callHandle = CXHandle(type: .generic, value: handleValue)
845
849
  let startCallAction = CXStartCallAction(call: uuid, handle: callHandle)
846
850
  let transaction = CXTransaction(action: startCallAction)
847
851
 
@@ -873,7 +877,8 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
873
877
  private func reportIncomingCall(from: String, niceName: String, uuid: UUID) {
874
878
  guard let provider = callKitProvider else { return }
875
879
 
876
- let callHandle = CXHandle(type: .generic, value: from)
880
+ let handleValue = niceName.isEmpty ? from : niceName
881
+ let callHandle = CXHandle(type: .generic, value: handleValue)
877
882
  let callUpdate = CXCallUpdate()
878
883
 
879
884
  callUpdate.remoteHandle = callHandle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-twilio-voice",
3
- "version": "8.0.32",
3
+ "version": "8.1.0",
4
4
  "description": "Integrates the Twilio Voice SDK into Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",