3

I’m using Twilio’s Programmable Voice in one of the projects. My primary requirement is to place VoIP class between mobile devices (no PSTN calls). I am able to place calls from one device to another, but unable to set appropriate Caller Name on Incoming Call screen.

Please guide me about how to display Caller’s name on receiving device. TVOCallInvite’s “from” value shows a mobile number “+18xxxxxxxx”, but I need to display the name of the caller. . We have created TwiML PHP file which contains the dialled client name and callerID (my twill number). We have assigned url of this file in TwiML app’s request URL (https://www.twilio.com/console/voice/twiml/apps/myappid).

We can assign name of the caller in CallKit’s “localizedCallerName”, but we are receiving phone number instead of caller’s identity.

Details: Tutorial Followed : https://github.com/twilio/voice-quickstart-swift TwilioVoice -> 2.0.0 iOS Version : 10.1 Device : iPhone 7 & iPhone 5S

Please find the attached screenshot.

enter image description here

Please note that I have searched google but I could not found the answer.

Thanks.

Below is my voice.php file

<?php

require __DIR__ . '/TwilioSdk/Twilio/autoload.php';
include('config.php');
use Twilio\Twiml;
$response = new Twiml;

if (isset($_REQUEST['To']) && strlen($_REQUEST['To']) > 0) 
{
  $number = htmlspecialchars($_REQUEST['To']);
  $dial = $response->dial(array('callerId' => $callerid)); // callerid is +18XXXXXXXXX
  if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) 
  {
    $dial->number($number);
  } 
  else 
  {
    $dial->client($number);
  }
} 
else 
{
   $response->say("Thanks for calling!");
}
header('Content-Type: text/xml');
echo $response;

?>

Twilio console for call logs

enter image description here

4

1 回答 1

0

Twilio developer evangelist here.

In order to get a name to appear on the iOS call screen in CallKit you need to pass a client identifier as the callerId rather than a phone number.

Client identifiers should be prefixed with client:. So in the code above, the important part is generating the TwiML, which should look like this:

$response->dial(array('callerId' => 'client:' . $clientName));

Note, you must use a number as a callerID if you a dialling a phone number. If you are dialling another client, then you can use a phone number or client identifier. If you want the name to appear in the application, then I recommend a client identifier as above.

于 2018-06-21T12:23:44.373 回答