Getting Started
Este contenido aún no está disponible en tu idioma.
-
Install the plugin
Ventana de terminal npm i @capgo/capacitor-twilio-videoVentana de terminal pnpm add @capgo/capacitor-twilio-videoVentana de terminal yarn add @capgo/capacitor-twilio-videoVentana de terminal bun add @capgo/capacitor-twilio-video -
Sync native platforms
Ventana de terminal npx cap syncVentana de terminal pnpm cap syncVentana de terminal yarn cap syncVentana de terminal bunx cap sync -
Issue a short-lived Twilio access token from your backend
- The plugin expects a valid Twilio Video access token before it can connect to a room.
- Keep room creation and token issuance on your server instead of hardcoding credentials in the app.
Permissions
Section titled “Permissions”Add the required usage descriptions on iOS:
<key>NSCameraUsageDescription</key><string>This app uses the camera for video calls.</string><key>NSMicrophoneUsageDescription</key><string>This app uses the microphone for video calls.</string>On Android, request camera and microphone access before joining a room.
Authenticate and join a room
Section titled “Authenticate and join a room”import { CapacitorTwilioVideo } from '@capgo/capacitor-twilio-video';
await CapacitorTwilioVideo.requestMicrophonePermission();await CapacitorTwilioVideo.requestCameraPermission();
await CapacitorTwilioVideo.login({ accessToken: 'TWILIO_ACCESS_TOKEN',});
await CapacitorTwilioVideo.joinRoom({ roomName: 'support-room', enableAudio: true, enableVideo: true,});Listen for room lifecycle events
Section titled “Listen for room lifecycle events”await CapacitorTwilioVideo.addListener('roomConnected', ({ roomName, participantCount }) => { console.log('Connected to room', roomName, participantCount);});
await CapacitorTwilioVideo.addListener('participantConnected', (event) => { console.log('Participant joined', event);});
await CapacitorTwilioVideo.addListener('roomReconnecting', () => { console.log('Reconnecting to Twilio Video');});Toggle local media
Section titled “Toggle local media”await CapacitorTwilioVideo.setMicrophoneEnabled({ enabled: false });await CapacitorTwilioVideo.setCameraEnabled({ enabled: true });
const status = await CapacitorTwilioVideo.getCallStatus();console.log(status.callState, status.participantCount);Leave the room
Section titled “Leave the room”await CapacitorTwilioVideo.leaveRoom();await CapacitorTwilioVideo.logout();Recommended architecture
Section titled “Recommended architecture”- Use this plugin for room connection and media state, not for token generation.
- Keep your visual call UI in your framework layer and react to plugin events.
- Rotate access tokens from your backend so reconnects and multi-device use stay secure.