Java iOS/android电话会议?
我没有合适的答案,所以我在这里 目前,我们正在应用程序中使用voip产品(一对一),但我们需要一对多 我想知道是否有可能使用twilio会议产品在移动设备(iOS/android)上进行电话会议,是否有可能将其与twilio客户端一起使用,或者我们是否必须自己对服务器执行一些http请求 或者有什么线索 根据这里的要求,代码用于1-1(仅限iOS,android不是我做的) 这是我的代币Java iOS/android电话会议?,java,android,ios,objective-c,twilio,Java,Android,Ios,Objective C,Twilio,我没有合适的答案,所以我在这里 目前,我们正在应用程序中使用voip产品(一对一),但我们需要一对多 我想知道是否有可能使用twilio会议产品在移动设备(iOS/android)上进行电话会议,是否有可能将其与twilio客户端一起使用,或者我们是否必须自己对服务器执行一些http请求 或者有什么线索 根据这里的要求,代码用于1-1(仅限iOS,android不是我做的) 这是我的代币 + (BOOL)getTwilioToken{ if(![self isCapabilityTok
+ (BOOL)getTwilioToken{
if(![self isCapabilityTokenValid]){
if([APP_DELEGATE currentUser].firstName && [APP_DELEGATE currentUser].lastName){
NSString *fullName = [NSString stringWithFormat:@"%@%@",[APP_DELEGATE currentUser].firstName,[APP_DELEGATE currentUser].lastName];
NSString *urlString = [NSString stringWithFormat:@"%@%@%@",TWILIO_BASE_URL,TWILIO_TOKEN_URL, fullName];
NSURL *url = [NSURL URLWithString:urlString];
NSString *token = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
[[NSUserDefaults standardUserDefaults] setObject:token forKey:@"capabilityToken"];
[[NSUserDefaults standardUserDefaults] synchronize];
return true;
}else{
return false;
}
}else{
return true;
}
}
下面的代码用于处理voip
- (void)setTwilioToken{
NSString* token = [[NSUserDefaults standardUserDefaults] objectForKey:@"capabilityToken"];
if(token){
self.phone = [[TCDevice alloc] initWithCapabilityToken:token delegate:self];
}
}
-(IBAction)callPressed:(id)sender{
//[self callResponder:sender];
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
//responder full name for twilio, client is required for twilio
NSString *responderFullName = [NSString stringWithFormat:@"client:%@%@",[[self.responders objectAtIndex:indexPath.row] firstName],[[self.responders objectAtIndex:indexPath.row] lastName]];
NSDictionary *params = @{@"To": responderFullName};
//Check to see if we can make an outgoing call and attempt a connection if so
NSNumber* hasOutgoing = [self.phone.capabilities objectForKey:TCDeviceCapabilityOutgoingKey];
if ( [hasOutgoing boolValue] == YES ){
//Disconnect if we've already got a connection in progress
if(self.connection){
[self.connection disconnect];
}
self.connection = [self.phone connect:params delegate:self];
[self closeNoddersView:nil];
}
}
- (void)connectionDidConnect:(TCConnection *)connection{
NSLog(@"Twilio connectionDidConnect");
NSError *errorAudio;
BOOL success = [[AVAudioSession sharedInstance]setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:&errorAudio];
[[AVAudioSession sharedInstance]setMode:AVAudioSessionModeVoiceChat error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
isSpeaker = success;
if(!success){
NSLog(@" error Audio %@", [errorAudio debugDescription]);
}
}
-(void)connection:(TCConnection*)connection didFailWithError:(NSError*)error
{
//Connection failed to responder failed
NSLog(@" %@", [error debugDescription]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[error localizedDescription]
message:@"We can't reach your responder"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
[self.connection disconnect];
}
这里是Twilio开发者福音传道者 正如我们在评论中指出的,您正在使用具有Python服务器的iOS客户端快速启动。如果您在整个过程中都遵循了快速启动,您将知道,当您发送一个
至
参数(该参数是一个电话号码)时,应用程序将调用该号码,当您发送至
参数时,该参数是一个以“client:”开头的字符串然后,您的应用程序将调用另一个基于客户端的应用程序。这一切都由服务器控制
当您从应用程序拨出时,Twilio使用您设置的参数调用Python服务器,以了解下一步要做什么。服务器返回TwiML(XML的一个子集)和指令。目前,它返回各种形式的数据,使用拨号到另一个客户端或只输入一个号码,拨出到电话网络
我们想要的是拨入电话会议
我们可以扩展Python服务器来实现这一点。您需要使用以下内容更新Python服务器:
@app.route('/call', methods=['GET', 'POST'])
def call():
resp = twilio.twiml.Response()
from_value = request.values.get('From')
to = request.values.get('To')
if not (from_value and to):
return str(resp.say("Invalid request"))
from_client = from_value.startswith('client')
caller_id = os.environ.get("CALLER_ID", CALLER_ID)
if not from_client:
# PSTN -> client
resp.dial(callerId=from_value).client(CLIENT)
elif to.startswith("client:"):
# client -> client
resp.dial(callerId=from_value).client(to[7:])
elif to.startswith("conference:"):
# client -> conference
resp.dial(callerId=from_value).conference(to[11:])
else:
# client -> PSTN
resp.dial(to, callerId=caller_id)
return str(resp)
我添加了以下几行:
elif to.startswith("conference:"):
# client -> conference
resp.dial(callerId=from_value).conference(to[11:])
这允许您指定一个类似于“conference:CONF_NAME”的to
参数。如果服务器收到此消息,它将返回TwiML,如下所示:
<Response>
<Dial>
<Conference>CONF_NAME</Conference>
</Dial>
</Response>
形态名称
这将使调用者进入名为CONF_name的会议。其他呼叫者可以通过提供相同的名称拨入同一会议
这是对quickstart的扩展,但希望您能看到如何使用它创建会议
让我知道这是否有帮助。你能分享你现在用来打1-1个电话的代码吗?我会看看我能不能建议你如何更新以打电话。@philnash完成并感谢你的帮助谢谢@Bryan D,很抱歉,很痛苦,你能分享你用来设置电话的TwiML吗?这在这种情况下更有用。谢谢@philnash现在我是唯一一个抱歉的人,我对twilio很陌生,所以你能更准确一点吗?你需要服务器端代码吗(我们遵循python快速启动),你需要“url”吗?啊,好的,你已经使用了python快速启动,这应该足够让我继续下去了!现在回答。最后我在服务器上设置了修改,它似乎工作得很好,我们可以通过python代码参加一个会议,现在我们有点棘手,因为没有关于调节部分的指南/图图。与我相比,您更喜欢创建一个新问题,还是我可以在这里向您寻求有关审核部分(静音、排除、获取会议名称等)的帮助查看此审核会议教程:。希望这是一个帮助,如果不是,最好打开一个新的问题,我们团队中的一员会找到它。很高兴听到你的应用程序正在工作!你介意接受我的回答,让其他人看到它的帮助吗?谢谢