@capgo/capacitor-twilio-voice 8.1.2 → 8.2.1

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; displayName?: string; }) => Promise<{ success: boolean; callSid?: string; }>
636
+ makeCall(options: { to: string; displayName?: string; callerId?: 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; displayName?: string; }</code> | - Configuration object |
644
+ | Param | Type | Description |
645
+ | ------------- | --------------------------------------------------------------------- | ---------------------- |
646
+ | **`options`** | <code>{ to: string; displayName?: string; callerId?: 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.1.2";
78
+ private final String pluginVersion = "8.2.1";
79
79
 
80
80
  private static final String TAG = "CapacitorTwilioVoice";
81
81
  private static final String PREF_ACCESS_TOKEN = "twilio_access_token";
@@ -122,6 +122,7 @@ public class CapacitorTwilioVoicePlugin extends Plugin {
122
122
  private PendingPermissionAction pendingPermissionAction = PendingPermissionAction.NONE;
123
123
  private PluginCall pendingOutgoingCall;
124
124
  private String pendingOutgoingTo;
125
+ private String pendingOutgoingCallerId;
125
126
  private PluginCall pendingPermissionCall;
126
127
  private long permissionRequestTimestamp = 0L;
127
128
  private int permissionAttemptCount = 0;
@@ -812,26 +813,29 @@ public class CapacitorTwilioVoicePlugin extends Plugin {
812
813
  if (to == null) {
813
814
  to = ""; // Empty string for echo test
814
815
  }
816
+ String callerId = call.getString("callerId");
815
817
 
816
818
  if (hasMicrophonePermission()) {
817
- startOutgoingCall(call, to);
819
+ startOutgoingCall(call, to, callerId);
818
820
  return;
819
821
  }
820
822
 
821
823
  pendingOutgoingCall = call;
822
824
  pendingOutgoingTo = to;
825
+ pendingOutgoingCallerId = callerId;
823
826
  pendingPermissionAction = PendingPermissionAction.OUTGOING_CALL;
824
827
  permissionAttemptCount = 0;
825
828
  call.setKeepAlive(true);
826
829
  requestMicrophonePermission();
827
830
  }
828
831
 
829
- private void startOutgoingCall(PluginCall call, String to) {
830
- Log.d(TAG, "startOutgoingCall: to=" + to);
832
+ private void startOutgoingCall(PluginCall call, String to, String callerId) {
833
+ Log.d(TAG, "startOutgoingCall: to=" + to + ", callerId=" + callerId);
831
834
  // Start call via the foreground service
832
835
  Intent serviceIntent = new Intent(getSafeContext(), VoiceCallService.class);
833
836
  serviceIntent.setAction(VoiceCallService.ACTION_START_CALL);
834
837
  serviceIntent.putExtra(VoiceCallService.EXTRA_CALL_TO, to);
838
+ serviceIntent.putExtra(VoiceCallService.EXTRA_CALLER_ID, callerId);
835
839
  serviceIntent.putExtra(VoiceCallService.EXTRA_ACCESS_TOKEN, accessToken);
836
840
 
837
841
  try {
@@ -920,10 +924,12 @@ public class CapacitorTwilioVoicePlugin extends Plugin {
920
924
  if (pendingPermissionAction == PendingPermissionAction.OUTGOING_CALL && pendingOutgoingCall != null) {
921
925
  PluginCall call = pendingOutgoingCall;
922
926
  String to = pendingOutgoingTo != null ? pendingOutgoingTo : "";
927
+ String callerId = pendingOutgoingCallerId;
923
928
  pendingOutgoingCall = null;
924
929
  pendingOutgoingTo = null;
930
+ pendingOutgoingCallerId = null;
925
931
  pendingPermissionAction = PendingPermissionAction.NONE;
926
- startOutgoingCall(call, to);
932
+ startOutgoingCall(call, to, callerId);
927
933
  return;
928
934
  }
929
935
 
@@ -1197,6 +1203,7 @@ public class CapacitorTwilioVoicePlugin extends Plugin {
1197
1203
  private void clearOutgoingPermissionState() {
1198
1204
  pendingOutgoingCall = null;
1199
1205
  pendingOutgoingTo = null;
1206
+ pendingOutgoingCallerId = null;
1200
1207
  if (pendingPermissionAction == PendingPermissionAction.OUTGOING_CALL) {
1201
1208
  pendingPermissionAction = PendingPermissionAction.NONE;
1202
1209
  }
@@ -20,7 +20,9 @@ import com.twilio.voice.CallException;
20
20
  import com.twilio.voice.CallInvite;
21
21
  import com.twilio.voice.ConnectOptions;
22
22
  import com.twilio.voice.Voice;
23
+ import java.util.HashMap;
23
24
  import java.util.List;
25
+ import java.util.Map;
24
26
 
25
27
  public class VoiceCallService extends Service {
26
28
 
@@ -37,6 +39,7 @@ public class VoiceCallService extends Service {
37
39
 
38
40
  // Intent extras
39
41
  public static final String EXTRA_CALL_TO = "CALL_TO";
42
+ public static final String EXTRA_CALLER_ID = "CALLER_ID";
40
43
  public static final String EXTRA_ACCESS_TOKEN = "ACCESS_TOKEN";
41
44
  public static final String EXTRA_CALL_INVITE = "CALL_INVITE";
42
45
  public static final String EXTRA_CALL_SID = "CALL_SID";
@@ -195,6 +198,7 @@ public class VoiceCallService extends Service {
195
198
 
196
199
  private void handleStartCall(Intent intent) {
197
200
  String to = intent.getStringExtra(EXTRA_CALL_TO);
201
+ String callerId = intent.getStringExtra(EXTRA_CALLER_ID);
198
202
  String accessToken = intent.getStringExtra(EXTRA_ACCESS_TOKEN);
199
203
 
200
204
  if (accessToken == null || accessToken.isEmpty()) {
@@ -209,8 +213,15 @@ public class VoiceCallService extends Service {
209
213
  startForeground(VOICE_NOTIFICATION_ID, createOngoingCallNotification("Connecting...", false));
210
214
 
211
215
  ConnectOptions.Builder builder = new ConnectOptions.Builder(accessToken);
216
+ Map<String, String> params = new HashMap<>();
212
217
  if (to != null && !to.isEmpty()) {
213
- builder.params(java.util.Collections.singletonMap("to", to));
218
+ params.put("to", to);
219
+ }
220
+ if (callerId != null && !callerId.isEmpty()) {
221
+ params.put("callerId", callerId);
222
+ }
223
+ if (!params.isEmpty()) {
224
+ builder.params(params);
214
225
  }
215
226
 
216
227
  activeCall = Voice.connect(this, builder.build(), callListener);
package/dist/docs.json CHANGED
@@ -90,12 +90,12 @@
90
90
  },
91
91
  {
92
92
  "name": "makeCall",
93
- "signature": "(options: { to: string; displayName?: string; }) => Promise<{ success: boolean; callSid?: string; }>",
93
+ "signature": "(options: { to: string; displayName?: string; callerId?: string; }) => Promise<{ success: boolean; callSid?: string; }>",
94
94
  "parameters": [
95
95
  {
96
96
  "name": "options",
97
97
  "docs": "- Configuration object",
98
- "type": "{ to: string; displayName?: string | undefined; }"
98
+ "type": "{ to: string; displayName?: string | undefined; callerId?: string | undefined; }"
99
99
  }
100
100
  ],
101
101
  "returns": "Promise<{ success: boolean; callSid?: string | undefined; }>",
@@ -112,6 +112,10 @@
112
112
  "name": "param",
113
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
114
  },
115
+ {
116
+ "name": "param",
117
+ "text": "options.callerId - Optional caller ID/phone number to send to your\nTwiML app so the backend can set the outbound `From` value instead of\ndefaulting to the contact URI."
118
+ },
115
119
  {
116
120
  "name": "returns",
117
121
  "text": "Promise that resolves with success status and call SID"
@@ -126,7 +130,7 @@
126
130
  },
127
131
  {
128
132
  "name": "example",
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```"
133
+ "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\n// Call a PSTN number using a specific caller ID\nawait CapacitorTwilioVoice.makeCall({\n to: '+1234567890',\n callerId: '+10987654321'\n});\n```"
130
134
  }
131
135
  ],
132
136
  "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.",
@@ -133,6 +133,9 @@ export interface CapacitorTwilioVoicePlugin {
133
133
  * @param options.displayName - Optional human-readable name used as the
134
134
  * iOS CXHandle value so Phone.app Recents renders a readable label
135
135
  * instead of the raw `to` identity.
136
+ * @param options.callerId - Optional caller ID/phone number to send to your
137
+ * TwiML app so the backend can set the outbound `From` value instead of
138
+ * defaulting to the contact URI.
136
139
  * @returns Promise that resolves with success status and call SID
137
140
  * @returns success - Whether the call was initiated successfully
138
141
  * @returns callSid - Unique identifier for this call (if successful)
@@ -150,11 +153,18 @@ export interface CapacitorTwilioVoicePlugin {
150
153
  * to: 'client:alice',
151
154
  * displayName: 'Alice Smith'
152
155
  * });
156
+ *
157
+ * // Call a PSTN number using a specific caller ID
158
+ * await CapacitorTwilioVoice.makeCall({
159
+ * to: '+1234567890',
160
+ * callerId: '+10987654321'
161
+ * });
153
162
  * ```
154
163
  */
155
164
  makeCall(options: {
156
165
  to: string;
157
166
  displayName?: string;
167
+ callerId?: string;
158
168
  }): Promise<{
159
169
  success: boolean;
160
170
  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 * @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"]}
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 * @param options.callerId - Optional caller ID/phone number to send to your\n * TwiML app so the backend can set the outbound `From` value instead of\n * defaulting to the contact URI.\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 * // Call a PSTN number using a specific caller ID\n * await CapacitorTwilioVoice.makeCall({\n * to: '+1234567890',\n * callerId: '+10987654321'\n * });\n * ```\n */\n makeCall(options: {\n to: string;\n displayName?: string;\n callerId?: string;\n }): 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"]}
package/dist/esm/web.d.ts CHANGED
@@ -16,6 +16,8 @@ export declare class CapacitorTwilioVoiceWeb extends WebPlugin implements Capaci
16
16
  }>;
17
17
  makeCall(_options: {
18
18
  to: string;
19
+ displayName?: string;
20
+ callerId?: string;
19
21
  }): Promise<{
20
22
  success: boolean;
21
23
  callSid?: string;
package/dist/esm/web.js CHANGED
@@ -2,6 +2,7 @@ import { WebPlugin } from '@capacitor/core';
2
2
  export class CapacitorTwilioVoiceWeb extends WebPlugin {
3
3
  // Authentication
4
4
  async login(_options) {
5
+ void _options;
5
6
  throw this.unimplemented('Not implemented on web.');
6
7
  }
7
8
  async logout() {
@@ -12,22 +13,28 @@ export class CapacitorTwilioVoiceWeb extends WebPlugin {
12
13
  }
13
14
  // Call Management
14
15
  async makeCall(_options) {
16
+ void _options;
15
17
  throw this.unimplemented('Not implemented on web.');
16
18
  }
17
19
  async acceptCall(_options) {
20
+ void _options;
18
21
  throw this.unimplemented('Not implemented on web.');
19
22
  }
20
23
  async rejectCall(_options) {
24
+ void _options;
21
25
  throw this.unimplemented('Not implemented on web.');
22
26
  }
23
27
  async endCall(_options) {
28
+ void _options;
24
29
  throw this.unimplemented('Not implemented on web.');
25
30
  }
26
31
  // Call Controls
27
32
  async muteCall(_options) {
33
+ void _options;
28
34
  throw this.unimplemented('Not implemented on web.');
29
35
  }
30
36
  async setSpeaker(_options) {
37
+ void _options;
31
38
  throw this.unimplemented('Not implemented on web.');
32
39
  }
33
40
  // Call Status
@@ -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;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, CallInvite } 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: CallInvite[];\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"]}
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,KAAK,QAAQ,CAAC;QACd,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,QAId;QACC,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA6B;QAC5C,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA6B;QAC5C,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAA8B;QAC1C,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IAChB,KAAK,CAAC,QAAQ,CAAC,QAA8C;QAC3D,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA8B;QAC7C,KAAK,QAAQ,CAAC;QACd,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, CallInvite } from './definitions';\n\nexport class CapacitorTwilioVoiceWeb extends WebPlugin implements CapacitorTwilioVoicePlugin {\n // Authentication\n async login(_options: { accessToken: string }): Promise<{ success: boolean }> {\n void _options;\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: {\n to: string;\n displayName?: string;\n callerId?: string;\n }): Promise<{ success: boolean; callSid?: string }> {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n\n async acceptCall(_options: { callSid: string }): Promise<{ success: boolean }> {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n\n async rejectCall(_options: { callSid: string }): Promise<{ success: boolean }> {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n\n async endCall(_options: { callSid?: string }): Promise<{ success: boolean }> {\n void _options;\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 void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n\n async setSpeaker(_options: { enabled: boolean }): Promise<{ success: boolean }> {\n void _options;\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: CallInvite[];\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorTwilioVoice = registerPlugin('CapacitorTwilioVoice', {\n web: () => import('./web').then((m) => new m.CapacitorTwilioVoiceWeb()),\n});\nexport * from './definitions';\nexport { CapacitorTwilioVoice };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorTwilioVoiceWeb extends WebPlugin {\n // Authentication\n async login(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async logout() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isLoggedIn() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Management\n async makeCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async acceptCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async rejectCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async endCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Controls\n async muteCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async setSpeaker(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Status\n async getCallStatus() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Audio Permissions\n async checkMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async requestMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,oBAAoB,GAAGA,mBAAc,CAAC,sBAAsB,EAAE;AACpE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;AAC3E,CAAC;;ACFM,MAAM,uBAAuB,SAASC,cAAS,CAAC;AACvD;AACA,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,yBAAyB,GAAG;AACtC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,2BAA2B,GAAG;AACxC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorTwilioVoice = registerPlugin('CapacitorTwilioVoice', {\n web: () => import('./web').then((m) => new m.CapacitorTwilioVoiceWeb()),\n});\nexport * from './definitions';\nexport { CapacitorTwilioVoice };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorTwilioVoiceWeb extends WebPlugin {\n // Authentication\n async login(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async logout() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isLoggedIn() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Management\n async makeCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async acceptCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async rejectCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async endCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Controls\n async muteCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async setSpeaker(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Status\n async getCallStatus() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Audio Permissions\n async checkMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async requestMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,oBAAoB,GAAGA,mBAAc,CAAC,sBAAsB,EAAE;AACpE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;AAC3E,CAAC;;ACFM,MAAM,uBAAuB,SAASC,cAAS,CAAC;AACvD;AACA,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;AAE1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,GAAG;AACvB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAE7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAE/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAE/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;AAE5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;AAE7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAE/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,aAAa,GAAG;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ;AACA,IAAI,MAAM,yBAAyB,GAAG;AACtC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,2BAA2B,GAAG;AACxC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorTwilioVoice = registerPlugin('CapacitorTwilioVoice', {\n web: () => import('./web').then((m) => new m.CapacitorTwilioVoiceWeb()),\n});\nexport * from './definitions';\nexport { CapacitorTwilioVoice };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorTwilioVoiceWeb extends WebPlugin {\n // Authentication\n async login(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async logout() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isLoggedIn() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Management\n async makeCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async acceptCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async rejectCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async endCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Controls\n async muteCall(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n async setSpeaker(_options) {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Status\n async getCallStatus() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Audio Permissions\n async checkMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async requestMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,oBAAoB,GAAGA,mBAAc,CAAC,sBAAsB,EAAE;IACpE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;IAC3E,CAAC;;ICFM,MAAM,uBAAuB,SAASC,cAAS,CAAC;IACvD;IACA,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAC7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,yBAAyB,GAAG;IACtC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,2BAA2B,GAAG;IACxC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorTwilioVoice = registerPlugin('CapacitorTwilioVoice', {\n web: () => import('./web').then((m) => new m.CapacitorTwilioVoiceWeb()),\n});\nexport * from './definitions';\nexport { CapacitorTwilioVoice };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorTwilioVoiceWeb extends WebPlugin {\n // Authentication\n async login(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async logout() {\n throw this.unimplemented('Not implemented on web.');\n }\n async isLoggedIn() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Management\n async makeCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async acceptCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async rejectCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async endCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Controls\n async muteCall(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n async setSpeaker(_options) {\n void _options;\n throw this.unimplemented('Not implemented on web.');\n }\n // Call Status\n async getCallStatus() {\n throw this.unimplemented('Not implemented on web.');\n }\n // Audio Permissions\n async checkMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async requestMicrophonePermission() {\n throw this.unimplemented('Not implemented on web.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,oBAAoB,GAAGA,mBAAc,CAAC,sBAAsB,EAAE;IACpE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAC;IAC3E,CAAC;;ICFM,MAAM,uBAAuB,SAASC,cAAS,CAAC;IACvD;IACA,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;IAE1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,GAAG;IACvB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAE7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAE/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAE/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAE5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,QAAQ,CAAC,QAAQ,EAAE;IAE7B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAE/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ;IACA,IAAI,MAAM,yBAAyB,GAAG;IACtC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,2BAA2B,GAAG;IACxC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -11,6 +11,7 @@ let kCachedDeviceToken = "CachedDeviceToken"
11
11
  let kCachedBindingDate = "CachedBindingDate"
12
12
  let kCachedAccessToken = "CachedAccessToken"
13
13
  let twimlParamTo = "to"
14
+ let twimlParamCallerId = "callerId"
14
15
 
15
16
  public protocol PushKitEventDelegate: AnyObject {
16
17
  func credentialsUpdated(credentials: PKPushCredentials)
@@ -27,7 +28,7 @@ public protocol PushKitEventDelegate: AnyObject {
27
28
  */
28
29
  @objc(CapacitorTwilioVoicePlugin)
29
30
  public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEventDelegate {
30
- private let pluginVersion: String = "8.1.2"
31
+ private let pluginVersion: String = "8.2.1"
31
32
 
32
33
  public let identifier = "CapacitorTwilioVoicePlugin"
33
34
  public let jsName = "CapacitorTwilioVoice"
@@ -66,6 +67,7 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
66
67
  let completion: (Bool) -> Void
67
68
  let isSystemInitiated: Bool
68
69
  let displayName: String?
70
+ let callerId: String?
69
71
  }
70
72
  private var pendingOutgoingCalls: [UUID: PendingOutgoingCall] = [:]
71
73
 
@@ -378,6 +380,7 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
378
380
  }
379
381
 
380
382
  let displayName = call.getString("displayName")
383
+ let callerId = call.getString("callerId")
381
384
 
382
385
  checkRecordPermission { [weak self] permissionGranted in
383
386
  guard permissionGranted else {
@@ -391,6 +394,7 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
391
394
  to: to,
392
395
  isSystemInitiated: false,
393
396
  displayName: displayName,
397
+ callerId: callerId,
394
398
  completion: { success in
395
399
  if success {
396
400
  call.resolve(["success": true, "callSid": uuid.uuidString])
@@ -454,6 +458,7 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
454
458
  to: handleValue,
455
459
  isSystemInitiated: true,
456
460
  displayName: displayName,
461
+ callerId: nil,
457
462
  completion: { _ in })
458
463
  }
459
464
  }
@@ -833,6 +838,7 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
833
838
  to: String,
834
839
  isSystemInitiated: Bool,
835
840
  displayName: String? = nil,
841
+ callerId: String? = nil,
836
842
  completion: @escaping (Bool) -> Void) {
837
843
  guard let provider = callKitProvider else {
838
844
  completion(false)
@@ -842,7 +848,8 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
842
848
  pendingOutgoingCalls[uuid] = PendingOutgoingCall(to: to,
843
849
  completion: completion,
844
850
  isSystemInitiated: isSystemInitiated,
845
- displayName: displayName)
851
+ displayName: displayName,
852
+ callerId: callerId)
846
853
 
847
854
  let handleValue = (displayName?.isEmpty == false ? displayName! : handle)
848
855
  let callHandle = CXHandle(type: .generic, value: handleValue)
@@ -907,9 +914,13 @@ public class CapacitorTwilioVoicePlugin: CAPPlugin, CAPBridgedPlugin, PushKitEve
907
914
  }
908
915
  }
909
916
 
910
- private func performVoiceCall(uuid: UUID, to: String, completionHandler: @escaping (Bool) -> Void) {
917
+ private func performVoiceCall(uuid: UUID, to: String, callerId: String?, completionHandler: @escaping (Bool) -> Void) {
911
918
  let connectOptions = ConnectOptions(accessToken: accessToken) { builder in
912
- builder.params = [twimlParamTo: to]
919
+ var params = [twimlParamTo: to]
920
+ if let callerId = callerId, !callerId.isEmpty {
921
+ params[twimlParamCallerId] = callerId
922
+ }
923
+ builder.params = params
913
924
  builder.uuid = uuid
914
925
  }
915
926
 
@@ -1146,7 +1157,8 @@ extension CapacitorTwilioVoicePlugin: CXProviderDelegate {
1146
1157
  let fallback = PendingOutgoingCall(to: handleValue,
1147
1158
  completion: { _ in },
1148
1159
  isSystemInitiated: true,
1149
- displayName: nil)
1160
+ displayName: nil,
1161
+ callerId: nil)
1150
1162
  pendingOutgoingCalls[uuid] = fallback
1151
1163
  pendingCall = fallback
1152
1164
  }
@@ -1190,7 +1202,7 @@ extension CapacitorTwilioVoicePlugin: CXProviderDelegate {
1190
1202
 
1191
1203
  provider.reportOutgoingCall(with: uuid, startedConnectingAt: Date())
1192
1204
 
1193
- performVoiceCall(uuid: uuid, to: to) { [weak self] success in
1205
+ performVoiceCall(uuid: uuid, to: to, callerId: callDetails.callerId) { [weak self] success in
1194
1206
  callDetails.completion(success)
1195
1207
  if !success {
1196
1208
  self?.emitOutgoingCallFailed(uuid: uuid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-twilio-voice",
3
- "version": "8.1.2",
3
+ "version": "8.2.1",
4
4
  "description": "Integrates the Twilio Voice SDK into Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",