Warm tip: This article is reproduced from serverfault.com, please click

How to make a WhatsApp call from app

发布于 2021-02-08 11:26:38

I want to make a WhatsApp call to a contact from my app, I already searched a lot, and did not find any answer, seems like it's restricted to OS only, but these questions are a little outdated

eg: Url scheme for making WhatsApp call programmatically from iOS app (voice call VOIP)?

and: How can I place a WhatsApp call from an iOS app?

also in WhatsApp docs: https://faq.whatsapp.com/iphone/how-to-link-to-whatsapp-from-a-different-app

I am trying to find if it's possible in 2021 or not yet

Thank you

Questioner
Elias Al Zaghrini
Viewed
0
Rafael Veronezi 2021-02-08 22:52:36

The first thing to consider here is that "calling through WhatsApp" is a feature of the WhatsApp itself and doesn't have any relation with features of the operating system.

So you need to understand that trying to make the call is actually an integration between your app and WhatsApp. You need to send a "message" to WhatsApp saying that you want it to make a call to the specified number. But how this is done? The mechanism in iOS this kind of inter app integration the use of URL Schemes.

On your app side, the way to this is already answered in one of your links:

 if #available(iOS 10.0, *) {
     UIApplication.shared.open(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
  } else {
     UIApplication.shared.openURL(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
  }

This is the right API. The thing is, it's up to the app maker (in this case WhatsApp) to decide which features it makes available to other apps to be requested, via a custom URL. Now one of the references that you sent is the official WhatsApp docs. There are examples of URL's that you need to call to integrate with WhatsApp, but I couldn't find anything related to start a call.

Probably WhatsApp developers haven't added a specific interface to allow this kind of integration, but it may be undocumented because you can do this from Siri Shortcuts, and it uses mostly the URL Scheme mechanism. Here's a reference that might be helpful to try to find the available schemes.