Skip to main content
@capgo/capacitor-twilio-voice Communication Open source

Twilio Voice Capacitor plugin

Make and receive VoIP calls with Twilio Voice for in-app calling functionality

Install

bun add @capgo/capacitor-twilio-voice bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-twilio-voice
  • pnpm add @capgo/capacitor-twilio-voice
  • yarn add @capgo/capacitor-twilio-voice

Guide

How to use Twilio Voice in Capacitor

Using @capgo/capacitor-twilio-voice

Integrates the Twilio Voice SDK into Capacitor.

Install

bun add @capgo/capacitor-twilio-voice
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

API at a glance

Method Description
login Authenticate the user with Twilio Voice using an access token.
logout Log out the current user and unregister from Twilio Voice.
isLoggedIn Check if the user is currently logged in and has a valid access token.
makeCall Initiate an outgoing call to a phone number or client.
acceptCall Accept an incoming call.
rejectCall Reject an incoming call.
endCall End an active call.
muteCall Mute or unmute the microphone during an active call.
setSpeaker Enable or disable speakerphone mode.
getCallStatus Get the current status of the active call.
checkMicrophonePermission Check if microphone permission has been granted.
requestMicrophonePermission Request microphone permission from the user.

Examples

login()

Authenticate the user with Twilio Voice using an access token.

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

const result = await CapacitorTwilioVoice.login({
  accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
});
console.log('Login successful:', result.success);

logout()

Log out the current user and unregister from Twilio Voice.

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

const result = await CapacitorTwilioVoice.logout();
console.log('Logout successful:', result.success);

isLoggedIn()

Check if the user is currently logged in and has a valid access token.

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

const status = await CapacitorTwilioVoice.isLoggedIn();
if (status.isLoggedIn && status.hasValidToken) {
  console.log('User identity:', status.identity);
} else {
  // Re-authenticate the user
}

makeCall()

Initiate an outgoing call to a phone number or client.

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

// Call a phone number
const result = await CapacitorTwilioVoice.makeCall({
  to: '+1234567890'
});
console.log('Call SID:', result.callSid);

// Call another Twilio client with a readable name for CallKit Recents
await CapacitorTwilioVoice.makeCall({
  to: 'client:alice',
  displayName: 'Alice Smith'
});

// Call a PSTN number using a specific caller ID
await CapacitorTwilioVoice.makeCall({
  to: '+1234567890',
  callerId: '+10987654321'
});

acceptCall()

Accept an incoming call.

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

CapacitorTwilioVoice.addListener('callInviteReceived', async (data) => {
  console.log('Incoming call from:', data.from);
  const result = await CapacitorTwilioVoice.acceptCall({
    callSid: data.callSid
  });
  console.log('Call accepted:', result.success);
});

rejectCall()

Reject an incoming call.

import { CapacitorTwilioVoice } from '@capgo/capacitor-twilio-voice';

CapacitorTwilioVoice.addListener('callInviteReceived', async (data) => {
  if (shouldRejectCall(data.from)) {
    await CapacitorTwilioVoice.rejectCall({
      callSid: data.callSid
    });
  }
});

The table above lists the 12 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Listen to events

addListener returns a handle. Call handle.remove() when the screen unmounts, or CapacitorTwilioVoice.removeAllListeners() to clear every listener.

Full reference

Keep going from Using @capgo/capacitor-twilio-voice

If you are using Using @capgo/capacitor-twilio-voice to plan native plugin work, connect it with @capgo/capacitor-twilio-voice for the implementation detail in @capgo/capacitor-twilio-voice, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.

FAQ

Twilio Voice plugin FAQ

How do I install the Twilio Voice plugin in a Capacitor app?

Run "bun add @capgo/capacitor-twilio-voice" (or "npm install @capgo/capacitor-twilio-voice"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-twilio-voice" in your app code.

Does @capgo/capacitor-twilio-voice work with React, Vue and Angular?

Yes. Twilio Voice is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-twilio-voice support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-twilio-voice free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-twilio-voice/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Twilio Voice without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Twilio Voice changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo