sip_voip_plugin 1.0.4
sip_voip_plugin: ^1.0.4 copied to clipboard
A simple Flutter plugin for SIP VoIP calling with CallKit support. Supports single and multi-account SIP registrations.
VoIP Plugin for Flutter #
A simple and powerful Flutter plugin for SIP VoIP calling with native CallKit support. Supports both single and multi-account SIP registrations.
Features #
- ✅ Simple API - Just a few methods to use
- ✅ Automatic CallKit UI - Incoming calls show native UI automatically
- ✅ Single & Multi-Account - Register one or multiple SIP accounts simultaneously
- ✅ Cross-Platform - Works on iOS and Android
- ✅ Automatic Reconnection - Handles network interruptions gracefully
- ✅ Call State Management - Comprehensive call state tracking and logging
- ✅ WebSocket Support - Supports both TCP/UDP and WebSocket (WSS) connections
Installation #
Add this to your pubspec.yaml:
dependencies:
voip_plugin: ^1.0.0
Then run:
flutter pub get
Quick Start #
Single Account Usage #
import 'package:voip_plugin/voip_plugin.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize plugin
await VoipPlugin.initialize();
// Register with SIP server
await VoipPlugin.register(
domain: 'sip.example.com',
username: '1001',
password: 'password',
realm: 'wss://ws.example.com',
callerId: 'John Doe',
);
// Make a call
await VoipPlugin.makeCall('1002');
runApp(MyApp());
}
Multi-Account Usage #
import 'package:voip_plugin/voip_plugin.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize multi-account plugin
await MultiVoipPlugin.initialize();
// Register multiple accounts
final account1 = await MultiVoipPlugin.registerAccount(
domain: 'sip.example.com',
username: '1001',
password: 'password1',
accountId: 'account1',
);
final account2 = await MultiVoipPlugin.registerAccount(
domain: 'sip.example.com',
username: '1002',
password: 'password2',
accountId: 'account2',
);
// Make calls from specific account
await MultiVoipPlugin.makeCall(
accountId: account1,
target: '1003',
);
runApp(MyApp());
}
⚠️ Setup Required #
IMPORTANT: This plugin requires manual configuration of Android and iOS permissions. Flutter plugins cannot automatically add these permissions.
Android Setup (Required) #
Add permissions to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.USE_SIP"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
iOS Setup (Required) #
Add to ios/Runner/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access for VoIP calls</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
</array>
API Reference #
VoipPlugin (Single Account) #
Methods
initialize()- Initialize the pluginregister(...)- Register with SIP serverunregister()- Unregister from SIP servermakeCall(String target)- Make a SIP callanswerCall()- Answer incoming callhangup()- Hangup current calldispose()- Cleanup
Properties
isRegistered- Check if registeredisInCall- Check if in call
Callbacks
onRegistrationChanged- Registration state callbackonCallStateChanged- Call state callbackonIncomingCall- Incoming call callback
MultiVoipPlugin (Multi-Account) #
Methods
initialize()- Initialize multi-account pluginregisterAccount(...)- Register a new account (returns account ID)unregisterAccount(String accountId)- Unregister accountmakeCall({accountId, target})- Make call from accountanswerCall(String accountId)- Answer callhangup(String accountId)- Hangup calldispose()- Cleanup all accounts
Properties
registeredAccounts- List of registered accountsgetAccount(String accountId)- Get account by IDisAccountRegistered(String accountId)- Check if account registeredisAccountInCall(String accountId)- Check if account in call
Documentation #
- Setup Instructions - ⚠️ Required setup steps
- Plugin Usage Guide - Complete usage documentation
- Multi-Account Guide - Multi-account usage
- Demo SIP Servers - Free test servers
- SIP Guide - SIP configuration guide
Example #
See example/ directory for complete example apps.
Requirements #
- Flutter SDK: >=3.0.0
- Dart SDK: >=3.0.0
- iOS: 12.0+
- Android: API 21+
Dependencies #
flutter_callkit_incoming- CallKit integrationsip_ua- SIP protocol implementationflutter_webrtc- WebRTC for audio/videopermission_handler- Permission managementuuid- UUID generation
License #
MIT License - see LICENSE file for details.
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
Support #
For issues and questions, please open an issue on GitHub.