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.
-
1. Do you want the user tap a "phone number" text to do this? – om-ha Jan 21 '20 at 00:45
-
2. Does the user choose what app to initiate the video call from? – om-ha Jan 21 '20 at 00:45
-
The idea is they click a button or image or whatever may be and it opens the phones native video call capabilities. – Sam Cromer Jan 21 '20 at 00:46
-
So again, you just want the user to tap a button/image. And open the "native" video call app. Without passing any parameter on whom the user is calling. – om-ha Jan 21 '20 at 00:58
-
No we will pass the number – Sam Cromer Jan 21 '20 at 01:00
-
What apps do you want to receive the "video call" on each platform? I'll assume for iOS it's FaceTime video call, how about Android? – om-ha Jan 21 '20 at 01:07
-
android would just use the video call option that is in contacts that i have seen – Sam Cromer Jan 21 '20 at 01:32
-
So is this not possible? I’ve been looking for a way to do this since last year – Sam Cromer Jan 21 '20 at 15:01
-
It's possible in iOS via Facetime. As for Android, well you have to implement it yourself via intents and go over each application intent manually via native Android code, which is error-prone. Anyways I'll be sharing my answer now. – om-ha Jan 21 '20 at 18:41
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 usingandroid.intent.action.CALL
, or just useandroid.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.

- 3,102
- 24
- 37
-
Thanks for all the info! So whats our best option for android? We wanted to stay away from third party but it looks like we cant. With those 3rd party options do they work as simple as pass it a number and it works? – Sam Cromer Jan 22 '20 at 00:39
-
Yeah they do. But there's a caveat that... since this is not a platform-provided video-call service then both caller & callee must have the same service. Suppose you went for option **B** in the answer. You'd use a 3rd-party one-to-one video call SDK or your own implementation of WebRTC. In that case if you **Sam** already have my number and try to video call me **om-ha** from your app via said 3rd-party or in-house video call solution, then if I don't have your app installed (i.e. don't have that solution on my device) it wouldn't work at all and you wouldn't be able to call me. – om-ha Jan 22 '20 at 05:49
-
As for option **A** however. Since there's no platform-provided solution on Android for video calling then you still have the same caveat as option **B** but in a different way. The more "top rated" video-calling apps you cover with your intents the better, and as a fallback you can use my solution above to do the voice-call. The more responsive you are with your updates to those intents (according to each app's updated intent specification) the safer you are from having failed intents when an app is available for them. Note this HAS to be done natively in Android via a platform method. – om-ha Jan 22 '20 at 05:58
-
Supplementary to intents in option **A**, some apps offer (with or without intents) API for interoperation or deep linking like [Skype](https://learn.microsoft.com/en-us/skype-sdk/skypeuris/skypeuris). In conclusion, as long as you want callers to call callees that haven't installed your app, then I see option **A** solution valid for both Android and iOS with a fallback to native video-call or voice-call. – om-ha Jan 22 '20 at 06:02
-
Thank u.. one more question. Is there a way to open device contacts? We don’t want to pull them into the app just want to launch contacts on the device – Sam Cromer Jan 22 '20 at 13:54
-
@SamCromer yeah that's totally possible. Check out [contacts_service](https://pub.dev/packages/contacts_service). All the info and permissions needed are there. – om-ha Jan 22 '20 at 14:55
-
I’m using that already but we want to actually open the contacts on the device like url_launcher – Sam Cromer Jan 22 '20 at 15:00
-
@om-ha your `few SDKs` link is broken, kindly update it or remove it. Thanks a lot. – Kamlesh Aug 10 '21 at 08:44
-
Sadly I no longer have the resource, I will have to delete the comment. Thanks for pointing that out. – om-ha Aug 10 '21 at 09:37
-
Original comment without the link: If you're fine with callers being able to ONLY call callees who have installed your app, then go with option B. You'll have to look for those SDK's, there are plenty online. Keywordsare: Video Calling, Video Conferencing (SDK or Services) – om-ha Aug 10 '21 at 09:39