Zum Inhalt springen

@capgo/capacitor-twilio-voice

Integrate Twilio Voice API for high-quality VoIP calling with call management, audio controls, and real-time communication.

Overview

The Capacitor Twilio Voice plugin enables high-quality VoIP calling functionality in iOS and Android applications using Twilio’s Voice API. This plugin provides comprehensive call management, authentication, and audio controls for creating professional calling experiences.

VoIP calling

High-quality voice calls over internet using Twilio Voice API 📞

Call management

Make, accept, reject, and end calls with full lifecycle control 🎛️

Audio controls

Mute, speaker toggle, and audio routing options 🎤

Platform support

Native iOS and Android implementation with push notifications 📱

Installation

Terminal window
npm install @capgo/capacitor-twilio-voice
npx cap sync

Core API Methods

Authentication

  • login(options: { accessToken: string }) - Authenticate with Twilio using access token
  • logout() - End user session and clear call state
  • isLoggedIn() - Check current authentication status

Call Management

  • makeCall(options: { to: string }) - Initiate outgoing call to specified number
  • acceptCall(options: { callSid: string }) - Accept incoming call
  • rejectCall(options: { callSid: string }) - Reject incoming call
  • endCall(options?: { callSid?: string }) - Terminate active call
  • muteCall(options: { muted: boolean, callSid?: string }) - Mute/unmute call audio
  • setSpeaker(options: { enabled: boolean }) - Toggle speaker output

Event Listeners

The plugin provides comprehensive event handling for:

  • Registration events for connection status
  • Call state changes (connected, disconnected, ringing)
  • Quality warnings and connection issues
  • Incoming call notifications

Platform Configuration

iOS Setup

  • Requires PushKit integration for incoming calls
  • Certificate configuration for production use
  • Microphone permissions in Info.plist

Android Setup

  • Firebase setup for push notifications
  • Microphone permissions in AndroidManifest.xml
  • Background service configuration

Quick Start Example

import { TwilioVoice } from '@capgo/capacitor-twilio-voice';
// Authenticate with Twilio
await TwilioVoice.login({ accessToken: 'your-twilio-access-token' });
// Make a call
await TwilioVoice.makeCall({ to: '+1234567890' });
// Listen for call events
TwilioVoice.addListener('callConnected', (data) => {
console.log('Call connected:', data);
});

Documentation

Check the complete documentation for detailed setup instructions, advanced configuration, and integration examples.