jefflinwood / twilio_client_phonegap

Phonegap plugins for the Twilio Client iOS and Android SDKs
MIT License
59 stars 53 forks source link

Unable to access the connect params in my application(Twiml voice url) #58

Open Jibin2015 opened 8 years ago

Jibin2015 commented 8 years ago

I am using a twilio calling functionality in my hybrid app and it was working fine before(both in android and IOS). But recently when i am trying to call it connects and disconnects.

I have done a research on this and find that the param (phonenumber) which i have passing from Twilio.Device.connect is not getting accessible from my application(voice url). When i put the phone number statically inside in my Twiml url function it works fine. I am using php as my server side. I have tried both in $_REQUEST and $_POST.

This is my code:

Twilio.Device.setup(data.token); Twilio.Device.ready(function (device) { var params = { "PhoneNumber" : phoneNumber}; Twilio.Connection.setSpeaker('off'); Twilio.Device.connect(params); app.activityStart('Calling..'); });

<?php header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; // put a phone number you've verified with Twilio to use as a caller ID number $callerId = "+23446434234"; // get the phone number from the page request parameters, if given if (isset($_REQUEST['PhoneNumber'])) { $number = htmlspecialchars($_REQUEST['PhoneNumber']); }

// wrap the phone number or client name in the appropriate TwiML verb // by checking if the number given has only digits and format symbols if (preg_match("/^[\d+-() ]+$/", $number)) { $numberOrClient = "" . $number . ""; } else { $numberOrClient = "" . $number . ""; } ?>

Any help??

jefflinwood commented 8 years ago

Hi,

It seems reasonable - what have you changed since it stopped working?

Jibin2015 commented 8 years ago

Hi, I haven't changed anything. I have also created one sample app to test the twilio calling functionality but there also it does not work for me and noticed that Twilio.Device.offline is triggered first instead of ready in android.

I tried your code in below link but it is not at all triggering my Twiml voice url. https://github.com/jefflinwood/TwilioClientPhoneGapExampleApp/blob/master/www/js/phoneApp.js

For me the Twilio.Device.connect will trigger my twiml voice url only if i put the connect method in offline event.

My cordova version is 4.2.0

jefflinwood commented 8 years ago

Hi, are you on Android 6.0 by any chance? The API level needs to be set to level 22 until the plugin gets an update - which I need to do.

On Tuesday, April 12, 2016, Jibin2015 notifications@github.com wrote:

Hi, I haven't changed anything. I have also created one sample app to test the twilio calling functionality but there also it does not work for me and noticed that Twilio.Device.offline is triggered first instead of ready in android.

I tried your code in below link but it is not at all triggering my Twiml voice url.

https://github.com/jefflinwood/TwilioClientPhoneGapExampleApp/blob/master/www/js/phoneApp.js

For me the Twilio.Device.connect will trigger my twiml voice url only if i put the connect method in offline event.

My cordova version is 4.2.0

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/jefflinwood/twilio_client_phonegap/issues/58#issuecomment-208951220

marcopadillo commented 8 years ago

I also encountered Twilio.Device.offline being triggered and not Twilio.Device.ready. But when I execute Twilio.Device.connect, it works.