Twilio TCDevice connect timeout - ios

I am wondering if there is a way to change the timeout on the outgoing call from [TCDevice -connect:delegate] in the Twilio iOS client. I have tried playing with different key/value pairs in the connect options NSDictionary but nothing seems to have an effect.

Megan from Twilio here.
For using timeout from the mobile client, you can embed the timeout parameter in the connect:delegate: method of TCDevice:
https://www.twilio.com/docs/api/client/ios/TCDevice#connectDelegate
For example:
NSDictionary *params = #{#"timeout": #"10"};
self.connection = [self.device connect:params delegate:self];
It sounds like you were trying this, but maybe missed to get this timeout argument in your TwiML app and add it into the response which is eventually sent to HUrl.

Related

How do you forward Twilio calls to different URLs in the middle of a call? (Using Node)

I'd like the following functionality with Twilio/Node: either
my server receives incoming call and the call rings on our custom client; at some point during the call (ideally can work before answering or after answering) or if no one answers on the client, the call is transferred to a webhook on a different server (my CRM provider) so the CRM can deal with it. OR
same as above, but the incoming call posts the incoming call request to both my server & my CRM webhook for the incoming call; I think this might not be possible though, not sure
I'm able to receive a Twilio call on my server without problem, and able to receive Twilio calls in my CRM without problem. However, when I tried to forward a call to the CRM after first receiving it on my custom server/client, it seems to always disconnect abrubtly. Pls help!
The code I'm using to update the call is below. The url works normally if sending the call directly to the CRM webhook. The CallSid is from my custom client from the incoming call
client.calls(req.body.CallSid)
.update({method: 'POST', url: 'https://crm.crmprovider.com/ctiapi/xml/cticall/twilio?authtoken=abc'})
Appreciate any help!
Think I figured out the proper way to do this. Should be using an "action" with "dial" and then checking "DialCallStatus" in the action endpoint and dealing with various statuses as appropriate. Sample code:
// On server, receive call. This is the url Twilio is
// set to post webhook to when call comes in
app.post('/incomingCall', (req, res) => {
const twiml = new VoiceResponse();
// Dial client first; after, call /callAction
// I believe this will call /callAction if call is unanswered for 10 seconds or after a completed call or if there's no client open
const dial = twiml.dial({timeout:10, action: '/callAction'});
const client = 'whateverClientName'
dial.client(client)
res.type('text/xml')
res.send(twiml.toString())
})
app.post('/callAction',(req,res)=>{
const twiml = new VoiceResponse();
// Can set below if for other things like if call not completed, answered, or cancelled
// In this example we say if call's not completed, route call to 3rd party site's webhook to further deal with the ongoing call
if(req.body.DialCallStatus!=='completed'){
twiml.redirect({method: 'POST'},'https://thirdpartywebhook.com/abc')}
else {twiml.hangup()}
res.type('text/xml')
res.send(twiml.toString())
})
I didn't find Twilio docs super straightforward on this so hopefully this helps someone in the future!

Twilio Call Issue from iOS App to Phone

I am trying to make call from my app to phone, My app executes a POST Request in which i am passing following parameters.
CallUrl = “https://api.twilio.com/2010-04- 01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Calls.json”
From = “+MyTwilioNumber”
To = “+9179XXXXXXXX”
Url = “myserveraddress.com/data.xml”
AuthToken = “cdXXXXXXXXXXXXXXXXX”
AccountSid = “ACXXXXXXXXXXXXXXXX”
Url Returns-
<Response>
<Dial>
<Number>+9179XXXXXXXX</Number>
</Dial>
</Response>
Now what happens is that when call is received, I hear the number you are trying to call is busy.
Can anybody help me what’s going wrong ???
Also how can I get call status in my App like call is ringing, answered, disconnected ???
Twilio developer evangelist here.
It sounds like you are making the call correctly and just dialling a busy number. If that's not the case, then let me know and I'll see if I can help further.
As for getting events for when the call is ringing, answered, disconnected etc, you need to check out the statusCallback parameter. You pass a URL to get webhooks when the statuses you want to hear about (chosen via the statusCallbackEvent parameter happen.
Let me know if that helps at all.

Call method for Twilio on Parse Cloud Code

We are trying to implement simple P2P VoIP connection between iOS devices. We picked Twilio to handle calls and using Parse to interact with Twilio.
We are successfully generating capability tokens per user and initiate a call. However call is hanging up instantly after successful connection.
Receiver is receiving the call successfully and hearing the trial message.
Initiator is hearing the trial message and also "Application error occurred.".
We are suspecting that there may be something wrong at our call method on Parse Cloud Code.
app.get('/call', function(request, response) {
var client = require('twilio')('ACC_ID', 'AUTH_ID');
// Create a TwiML response generator object
var fromName = 'client:' + request.query.from;
var toName = 'client:' + request.query.to;
client.makeCall({
to:toName, // Any number Twilio can call
from: fromName,
url: 'http://xxxyyzz.parseapp.com/consult' // A URL that produces an XML document (TwiML) which contains instructions for the call
}, function(err, responseData) {
//executed when the call has been initiated.
console.log(responseData.from); // outputs "+14506667788"
});
});
We are not sure about what should url parameter supposed to do.
app.post('/consult', function(request, response) {
response.send();
});
Thanks.
You are almost there, but there seems to be a problem in your /call service (you also don't need any other urls, /call' should be enough).
What Twilio expects as a response from /call is a TwiML message (https://www.twilio.com/docs/api/twiml). Your server here should respond proper TwiML so that Twilio will know what to do.
If you want to connect two clients then /call should return the Dial TwiML message. The documentation (https://www.twilio.com/docs/api/twiml/dial) can let you know about the details of the Dial message. There are some interesting options such as limiting the phone call to 40 seconds for example.
If you want to dial a client called 'Jenna', then the response from your /call service should be:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Client>Jenna</Number>
</Dial>
</Response>
Good luck with your application, hope this helps!

how to configure socket io in server to get acknowledge (SocketIOCallback) from ios socket

I am developing a chat app in ios with node.js and socket.io. I use SocketIOCallback to send acknowledgement. But i don't getting any acknowledgement on server.js. Here is the code i use to send acknowledge
SocketIOCallback cb = ^(id argsData) {
NSDictionary *response = argsData;
// do something with response
NSLog(#"ack arrived: %#", response);
};
[socketIO sendEvent:#"message" withData:values andAcknowledge:cb];
server.js
socket.on('message', function(postMessage,callback){
console.log(callback);
//callback('okkk');
console.log('username-->'+ socket.username);
console.log('ID-->'+ socket.id);
io.sockets.emit("pvt",socket.username,postMessage+socket.username);
io.sockets.emit("pvt",socket.username,postMessage+socket.username);
});
when printing console.log(callback) it show unknown in terminal
How to configure server.js to get these acknowledgement from ios app. Or how to send acknowledgement from server to ios app and vice versa Please help me to solve these problem with example. Thanks in advance
I found a solution which consists on changing emit method to emitEvent. Hope it really help you.

How can I setup twilio call record?

I have an iOS app with Twilio calls and voice record.
I'm using Twilio Client iOS SDK.
When user want to call the connection is created with code:
TCDevice* _device ...;
TCConnection* _connection ...;
NSDictionary* parameters = nil;
parameters = [NSDictionary dictionaryWithObjectsAndKeys:
phoneNumber,#"userId",
#"false",#"record",
nil];
_connection = [_device connect:parameters delegate:self];
When user want to record voice message I use this parameters:
parameters = [NSDictionary dictionaryWithObjectsAndKeys:
phoneNumber,#"userId",
#"true",#"record",
nil];
Calls are always successful, but the record is often interrupted when the user speaks very softly or silence the first few seconds. In this case, the server returns a null Url of the record.
How can I cancel an interrupt call record if the silence?
Is it possible to remove the voice warning before the recording: "Please, leave a message after the beep"?
In which place it should be set: in an application, on home server or in the dev tools on Twilio?
Check out the Twilio docs on using recordings: https://www.twilio.com/docs/api/twiml/record
The default timeout is 5 seconds, which means if there is silence for 5 seconds (or perhaps someone speaking very softly) then the recording ends. Perhaps increasing the timeout will resolve this for you?

Resources