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

  • 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 Jun 14 '18 at 01:21
  • I have added code for the php file which i have set in twilml.Can you tell me where should i make change ? –  Jun 19 '18 at 07:08
  • 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 Jun 20 '18 at 00:10
  • Can you ask one of your twilio team member who have worked on it ? –  Jun 20 '18 at 09:42
  • Have you tried replacing the `callerId` with a client identifier rather than a phone number yet? – philnash Jun 20 '18 at 23:27
  • yes i have added identifier instead of phone by changing as - $dial = $response->dial(array('callerId' => clientidentifier)); but not working –  Jun 21 '18 at 05:10
  • What's not working? Do you still see a phone number? – philnash Jun 21 '18 at 11:18
  • Please check my question i have added snap. After setting client identifier what i get is some numbers in "from" –  Jun 21 '18 at 11:38
  • Oh, the caller does need to start with `client:` then the client ID. What did you see in the app? – philnash Jun 21 '18 at 11:40
  • Same name in both side caller and receiver –  Jun 21 '18 at 12:07
  • Can you please write syntax here. i can not understand what should i pass here $dial = $response->dial(array('callerId' => $callerid)); –  Jun 21 '18 at 12:08
  • 1
    `$response->dial(array('callerId' => 'client:' . $clientName));` So you are seeing a name on the incoming call to the iOS app now then? – philnash Jun 21 '18 at 12:11
  • Let me try it once –  Jun 21 '18 at 12:16
  • Thanks a lot it is working now :) thank you philnash for the great support. –  Jun 21 '18 at 12:20
  • Oh cool, I'll add an answer so that it's clear for everyone else. – philnash Jun 21 '18 at 12:20
  • Yes please. Some time a small word missing takes a longer timer to identify –  Jun 21 '18 at 12:21

1 Answers1

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.

philnash
  • 70,667
  • 10
  • 60
  • 88