I'ld like to make native call to user until user answer the call (Recursive call). If in case of voice mail than also doing same. Is it possible using Twilio
in my iOS application.
Also i want to know whether call is answered by human or machine.
If yes than please suggest me some solution.
you could do this by leveraging StatusCallBack
, Something like this:
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create("+18668675309", "+14155551212", "http://demo.twilio.com/docs/voice.xml", array(
"Method" => "GET",
"IfMachine"=>"Hangup",
"StatusCallback" => "https://www.myapp.com/check_call_status.php",
"StatusCallbackMethod" => "POST"
));
StatusCallBack: A URL that Twilio will send asynchronous webhook requests to on every call event specified in the StatusCallbackEvent parameter. If no event is present, Twilio will send completed by default. If an ApplicationSid parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted).
So in your StatusCallBack URL (https://www.myapp.com/check_call_status.php) you would have some logic to determine if the call was answered, and if it was answered by a human not an answering machine. Your StatusCallBack endpoint would look something like this:
<?php
if($_REQUEST['CallStatus'] == 'no-asnwer' || $_REQUEST['AnsweredBy'] == 'machine'){
// call again!
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create("+18668675309", "+14155551212", "http://demo.twilio.com/docs/voice.xml", array(
"Method" => "GET",
"IfMachine"=>"Hangup",
"StatusCallback" => "https://www.myapp.com/check_call_status.php",
"StatusCallbackMethod" => "POST"
));
}