Package selection guidance compiled from public package information, community data, and project usage.
The twilio_voice_flutter package enables Flutter applications to integrate voice-over-IP (VoIP) calling using Twilio's Voice SDK. It provides a bridge between Flutter and native Twilio Voice functionality on Android and iOS, allowing developers to build real-time communication features such as one-on-one calls, group calls, and call management. The package supports incoming and outgoing calls, call state handling, and audio session management. It is designed for apps requiring secure, scalable, and high-quality voice communication directly within the mobile app interface.
Use cases
In-app voice calling
Telehealth applications
Customer support chat with voice
Remote collaboration tools
Real-time customer service
Key features
Native VoIP integration
Call management APIs
Support for Android and iOS
Secure audio streaming
Incoming/outgoing call handling
Suitable for
Apps needing real-time voice communication
Healthcare and telemedicine platforms
Customer service and support apps
Collaborative work tools
Mobile apps with integrated calling
Considerations
Requires Twilio account and API credentials
Needs proper permissions for microphone and network access
Depends on native SDKs for full functionality
May require additional backend logic for token generation
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
The twilio_voice_flutter package simplifies integration with Twilio's Programmable Voice SDK, enabling VoIP calling within your Flutter apps. It supports both iOS and Android, offering an easy-to-use API for managing calls. Ideal for customer service, communication, or any app needing real-time voice, it leverages Twilio's reliable infrastructure to deliver high-quality VoIP features.
Getting started
Add dependency to your pubspec.yaml file & run Pub get
⚠️ This plugin requires Firebase setup for Twilio voice calls! It uses FCM tokens for handling calls on Android 📲 and VoIP notifications for iOS 📞. Ensure both platforms are properly configured for smooth call functionality. ⚠️
Platform Setup
Android
To integrate the Twilio Voice plugin into your Android project, follow these steps:
Open your project's AndroidManifest.xml file.
Add the following service declaration inside the <application> tag:
This plugin supports Twilio voice calls for both Android and iOS. To generate the access token and enable Twilio calls, follow the steps in the official Twilio repositories:
These repositories provide detailed instructions for generating access tokens and making voice calls through Twilio on both Android and iOS platforms. ⚡ Make sure to follow the steps outlined to successfully integrate Twilio voice functionality into your application.
Setting Up Twilio Token
The setTwilioToken function is used to register a user's identity with Twilio Voice using the provided access token. This function handles the retrieval of the Firebase Cloud Messaging (FCM) token on Android devices and registers the user with Twilio Voice.
The Twilio Voice Plugin for Flutter enables seamless integration of voice-over-IP (VoIP) calling into your Flutter applications. Below are the key features supported by this plugin:
1. VoIP Call Management
Initiate Calls: Easily start a VoIP call to any recipient using the makeCall method, with the ability to pass custom call data.
Receive Incoming Calls: Handle incoming call invites via push notifications, and answer calls using built-in CallKit support on iOS.
Call Status Notifications: Stay updated on call status changes such as ringing, connecting, and disconnecting through Flutter MethodChannel callbacks.
2. In-Call Controls
Mute/Unmute Calls: Toggle the mute status of the ongoing call using the toggleMute method. Check if the call is currently muted with the isMuted method.
Speakerphone Control: Switch between the device's built-in speaker and receiver during an ongoing call using toggleSpeaker. Verify the current audio route with isSpeaker.
3. CallKit Integration for iOS
CallKit Support: Utilize native CallKit functionality on iOS for managing incoming and outgoing VoIP calls, ensuring a familiar user experience.
Incoming Call Handling: Report incoming calls to CallKit, allowing the system to display the native call UI and handle interruptions correctly.
Background VoIP Support: Ensure your app can receive VoIP calls while in the background by enabling the necessary background modes and configuring the Info.plist accordingly.
4. Push Notification Support
VoIP Push Notifications: Register and handle VoIP push notifications via Firebase Cloud Messaging (FCM) on Android and Apple Push Notification service (APNs) on iOS.
Push Credential Management: Manage device and access tokens required for receiving VoIP push notifications, ensuring reliable communication.
5. DTMF (Dual-tone Multi-frequency) Signaling
Send DTMF Digits: During an active call, send DTMF tones (e.g., for interacting with automated phone systems) using the sendDigits method.
6. Contact Management
Custom Contact Data: Store and retrieve custom contact data (like display names and photo URLs) to enhance the calling experience with personalized information.
7. Persistent Data Storage
Token and Contact Data Persistence: Securely store and retrieve access tokens and contact data using UserDefaults on iOS to maintain state across app sessions.
8. Call Handling with Error Management
Graceful Error Handling: Comprehensive error handling ensures that issues like token expiration or failed call connections are managed and reported to the user effectively.
With these features, the Twilio Voice Plugin provides a robust foundation for integrating voice communication into your Flutter applications, supporting a wide range of use cases from customer support to in-app communication.
Function Overview
register():
Registers the device with Twilio using the access token and device token for VoIP push notifications.
unregister():
Unregisters the device from Twilio VoIP push notifications, removing the access token and device token.
makeCall(String to):
Initiates a voice call to the specified recipient. If an active call exists, it returns an error.
toggleMute():
Toggles the mute status of the ongoing call. Notifies the Flutter side of the change.
isMuted():
Returns the current mute status of the ongoing call.
toggleSpeaker():
Toggles the speaker mode during an ongoing call. Notifies the Flutter side of the change.
isSpeaker() -> Bool:
Checks if the speaker mode is currently active.
hangUp():
Ends the current call. If no active call exists, it clears the call-related data.
activeCall():
Returns details of the active call if one exists.
sendDigits(String digits):
Sends DTMF digits during an active call.