Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open video call flutter

Tags:

flutter

dart

Is there a solution yet for opening the video call function on the native phone in flutter? I have looked at Agora and others and none of them work the way we need them to.

like image 664
Sam Cromer Avatar asked Sep 07 '26 08:09

Sam Cromer


1 Answers

That was rather annoying to research and come up with, here it goes. This is the best I can come up with while keeping high complexity and paid SDK's outside the solution.

First of all, you have to differentiate between the two platforms (iOS/Android) before initiating the video call. Since there's no uniform solution for both platforms AFAIK.

import 'dart:io';

if (Platform.isAndroid) {
  // Android Video Call
} else if (Platform.isIOS) {
  // iOS Video Call
}

iOS

  • Install the infamous url_launcher pub.
  • You'll need to use FaceTime Links (see full iOS URL Scheme Reference here or here)
  • Text example: facetime:14085551234 this initiates FaceTime video call to 14085551234 (you use email instead of phone number too)
import 'package:url_launcher/url_launcher.dart';

final String url = 'facetime:$phoneNumber';
if (await canLaunch(url)) {
  await launch(url);
} else {
  throw 'Could not launch $url';
}

This works surprisingly well. In this case you can replace $phoneNumber variable with something like $userEmail variable.

Android

  • Install android_intent pub
  • Add CALL_PHONE permission and show its prompt to user if you're using android.intent.action.CALL, or just use android.intent.action.DIAL without the permission.

This is where the problem lies... I tried the following solution and it only worked for regular calls not video calls

import 'package:android_intent/android_intent.dart';


/// This acton calls the user directly via native phone app but requires `CALL_PHONE` permission in _AndroidManifest_.
final callIntentAction = 'android.intent.action.CALL';

/// This action displays native phone app with dial pad open showing the passed phone number intent's argument/extra. Does not require permissions as of Jan2020.
final dialIntentAction = 'android.intent.action.DIAL'; 

final intentAction = callIntentAction;

AndroidIntent intent = AndroidIntent(
    action: intentAction,
    data: Uri.encodeFull('tel:$phoneNumber'),
    arguments: {
        /// KEY: actual phone number to call [source](https://developer.android.com/reference/android/content/Intent.html#EXTRA_PHONE_NUMBER)
        /// VALUE: phoneNumber
        'android.intent.extra.PHONE_NUMBER': phoneNumber,

        /// KEY: [START_CALL_WITH_VIDEO_STATE](https://developer.android.com/reference/android/telecom/TelecomManager.html#EXTRA_START_CALL_WITH_VIDEO_STATE)
        /// VALUE: `3` implies [STATE_BIDIRECTIONAL](https://developer.android.com/reference/android/telecom/VideoProfile.html#STATE_BIDIRECTIONAL)
        'android.telecom.extra.START_CALL_WITH_VIDEO_STATE': '3',
    },
);
await intent.launch();

Error-handling side-note: unfortunately with android_intent pub there's no error handling or "canOpen" method like url_launcher.

Your problem still lies with Android as there's no native general-purpose video-call app.

You have a couple of options:

  • A. You can link with your app a video-calling SDK/capability either third-party or your own. (like flutter_webrtc, agora_flutter_webrtc, SightCall, quickblox). This has the downside that the callee has to be using the same software i.e. your app has to be installed on callee's device. This approach is more future-proof. Note I'm not affiliated with any of the libraries I mentioned.
  • B. You can make a platform method for Android to go over a defined set of intents and check the package name of known video-calling apps with the extra/arguments they require. You'd have to check the list of intents one by one and see which applies and resolves correctly. For apps like Google Duo, Whatsapp, Skype, etc.... This is EXTREMELY prone to errors. As explained here.
like image 131
om-ha Avatar answered Sep 10 '26 05:09

om-ha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!