问题
I am integrating the voip
, thus integrated twilio. I also setup the server code on heroku successfully. I create the token successfully, and getting the callback on handler as well. When I run the application on device, then callback in delegate comes
Device: <TCPresenceEvent 0x17de3840 name=jenny, available=YES> didReceivePresenceUpdate
After some time, below error occurred:
[ERROR TCMetricsPublisher] Failed to push call stats, status code: 403
Delegates callback:
- I got the callback in
connectionDidConnect
- After some time, I got the callback in
connectionDidDisconnect
automatically.
My code:
TCDevice* _phone;
TCConnection* _connection;
NSString *urlString = [NSString stringWithFormat:@"https://tatoll.herokuapp.com/token?client=%@", name];
NSURL *url = [NSURL URLWithString:urlString];
NSError *error = nil;
NSString *token = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
if (token == nil) {
NSLog(@"Error retrieving token: %@", [error localizedDescription]);
} else {
_phone = [[TCDevice alloc] initWithCapabilityToken:token delegate:self];
}
NSDictionary *params = @{@"To": self.numberField.text};
_connection = [_phone connect:params delegate:self];
回答1:
Receiving status code: 403
, usually suggests that you are providing the wrong credentials. Meaning, your account SID and Auth Token are either not supplied or you supplied the wrong ones.
You may want to validate that you are passing capability tokens properly. When you setup your capability token you need to use capability.allow_client_outgoing(application_sid) to enable outgoing calls.
from twilio.util import TwilioCapability
account_sid = "ACXXXXXXXXXXXXXXX"
auth_token = "secret"
application_sid = "AP123123"
capability = TwilioCapability(account_sid, auth_token)
capability.allow_client_incoming("tommy")
capability.allow_client_outgoing(application_sid)
print capability.generate()
If you find the former is set up correctly, some people have also run into this issue because they are not actually forwarding the call.
You are probably hearing this:
'Welcome to Twilio'
And then the call hangup. This is because your TwiML app is configured that way. If you would like to forward your call to another number. You have to configure your Twilio for call forwarding, like so:
<Response><Dial callerId='[replace with Twilio number]'>+86xxxxxxxxxxxxxx</Dial></Response>
来源:https://stackoverflow.com/questions/36599010/failed-to-push-call-stats-status-code-403-error-tcmetricspublisher-twilio