dial_videocall 0.0.4
dial_videocall: ^0.0.4 copied to clipboard
Dial VideoCall using OpenVidu on Flutter
Dial-VideoCall #
Dial VideoCall library using OpenVidu on Flutter
How to Install #
Step 1. Add the Dependencies to your pubspec.yaml #
Add it in your pubspec.yaml. Make sure you use the latest release version!
dependencies:
flutter:
sdk: flutter
dial_videocall: ^0.0.4
Step 2. Ask for permission #
To ensure all feature works, ask for camera and microphone permission before starting video call.
You can handle this process manually, or ease this process by using permission_handler.
Step 3. Handle Incoming Video Call #
On your project, handle the incoming call from FirebaseMessaging instance.
On below, this is example how to handle incoming call
Future<void> _checkIncomingNotification() async {
RemoteMessage initialMessage =
await FirebaseMessaging.instance.getInitialMessage();
if (initialMessage?.data !=null) {
sessionFrom = await initialMessage.data['session_from'];
sessionTo = await initialMessage.data['session_to'];
_goToCallPage();
}
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
if(message.notification!=null){
if(message.data!=null){
sessionFrom = message.data['session_from'];
sessionTo = message.data['session_to'];
_goToCallPage();
}
}
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
if (message.notification != null) {
print('Message also contained a notification: ${message.notification.toString()}');
if(message.data!=null){
sessionFrom = message.data['session_from'];
sessionTo = message.data['session_to'];
_goToCallPage();
}
}
});
}
After the FCM arrived, call _goToCallPage() method to start videocall.
void _goToCallPage(){
if(!isOnCall){
isOnCall = true;
DialVideoCall.startVideoCallDev(
context: context,
sessionFrom: sessionFrom,
sessionTo: sessionTo
).then((value) {
isOnCall = false;
sessionFrom = null;
sessionTo = null;
});
}
}
API #
We provide two method, to handle production and development:
Production
Method Call #
DialVideoCall.startVideoCall(context, sessionFrom, sessionTo);
Call This method when you want to start video call in production server
Production URL #
Change following parameter using your configuration:
- clientSid
- from
- to
- fcm_server_key
- fcm_token
At the end of parameter, after the #, fill it with to session name
Development
Method Call #
DialVideoCall.startVideoCallDev(context, sessionFrom, sessionTo);
Call This method when you want to start video call in development server
Production URL #
Change following parameter using your configuration:
- clientSid
- from
- to
- fcm_server_key
- fcm_token
At the end of parameter, after the #, fill it with to session name