H.HISTORY
H.HISTORY

Reputation: 518

using twilio php library in mobile devices (ios and android)?

I'm working on a simple application using twlio php library to make out going calls.

everything seems to be working as it should in web browser. However, when i test the simple php page in a mobile device (iphone for example), nothing works! I get the page loaded but I cannot make any outgoing calls!

this is my code:

<?php
include 'Services/Twilio/Capability.php';

// put your Twilio API credentials here
$accountSid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$authToken  = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

// put your Twilio Application Sid here
$appSid     = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

$capability = new Services_Twilio_Capability($accountSid, $authToken);
$capability->allowClientOutgoing($appSid);
$capability->allowClientIncoming('jenny');
$token = $capability->generateToken();
?>

<!DOCTYPE html>
<html>
  <head>
    <title>Hello Client Monkey 4</title>
    <script type="text/javascript"
      src="//static.twilio.com/libs/twiliojs/1.2/twilio.min.js"></script>
    <script type="text/javascript"
      src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
    </script>

    <script type="text/javascript">

      Twilio.Device.setup("<?php echo $token; ?>");

      Twilio.Device.ready(function (device) {
        $("#log").text("Ready");
      });

      Twilio.Device.error(function (error) {
        $("#log").text("Error: " + error.message);
      });

      Twilio.Device.connect(function (conn) {
        $("#log").text("Successfully established call");
      });

      Twilio.Device.disconnect(function (conn) {
        $("#log").text("Call ended");
      });

      Twilio.Device.incoming(function (conn) {
        $("#log").text("Incoming connection from " + conn.parameters.From);
        // accept the incoming connection and start two-way audio
        conn.accept();
      });

      function call() {
        // get the phone number to connect the call to
        params = {"PhoneNumber": $("#number").val()};
        Twilio.Device.connect(params);
      }

      function hangup() {
        Twilio.Device.disconnectAll();
      }
    </script>
  </head>
  <body>
    <button class="call" onclick="call();">
      Call
    </button>

    <button class="hangup" onclick="hangup();">
      Hangup
    </button>

    <input type="text" id="number" name="number"
      value="Phone Number/>

    <div id="log">Loading pigeons...</div>
  </body>
</html>

Could someone please advise on this issue? am I missing something?

Upvotes: 0

Views: 115

Answers (1)

philnash
philnash

Reputation: 73027

Twilio developer evangelist here.

Sadly iOS does not currently support either WebRTC or Flash, both of the technologies that Twilio Client uses to make phone calls from your web browser. So, Twilio Client JavaScript will not work on an iPhone. Recent versions of Chrome on Android do support WebRTC, so you should be able to use Twilio Client on those devices.

Upvotes: 1

Related Questions