3
votes

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

1
I'm guessing that the +18xxxxxxxx number is your Twilio number? When making client to client calls you don't need to use the Twilio number as a callerId, you can use a client identifier instead. Have you tried that?philnash
I have added code for the php file which i have set in twilml.Can you tell me where should i make change ?user9685203
I would suggest you change the callerId to a client identifier, like client:yourClientIdentifier. You should also be able to catch that identifier in the notification, replace it with a better identifier and update the display in the notification. I've not yet worked with CallKit myself though, so I'm not the best person to answer how you'd do that.philnash
Can you ask one of your twilio team member who have worked on it ?user9685203
$response->dial(array('callerId' => 'client:' . $clientName)); So you are seeing a name on the incoming call to the iOS app now then?philnash

1 Answers

0
votes

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.