【发布时间】:2017-08-05 06:14:51
【问题描述】:
我们正在 iOS 中创建一个录音应用程序,我们希望在该应用程序中提供一个功能来记录通话。对于从应用程序到手机的调用,我们使用的是 twilio iOS SDK。
如何使用 twilio iOS SDK 记录通话。
我们希望,如果用户启用录音到应用程序,那么通话应该得到录音,如果录音关闭,那么它不应该得到录音。
我们用于管理 twiml 的后端技术是 PHP。
用于拨打电话的代码我们编写了以下代码: -(void)callsetup:(NSString*)dialnumber{ NSString *CallerID = [[NSUserDefaults standardUserDefaults]objectForKey:PRPhoneNumber]; self.callViewController.mainText = dialnumber; [PKTPhone sharedPhone].callerId = CallerID; [[PKTPhone sharedPhone] call:dialnumber]; }
///*** PKTPhone class next working***
-(void)call:(NSString *)callee
{
[self call:callee withParams:nil];
}
- (void)call:(NSString *)callee withParams:(NSDictionary *)params
{
reciverID = callee;
if (!(self.phoneDevice && self.capabilityToken)) {
NSLog(@"Error: You must set PKTPhone's capability token before you make a call");
return;
}
NSMutableDictionary *connectParams = [NSMutableDictionary dictionaryWithDictionary:params];
if (callee.length)
connectParams[@"callee"] = callee;
if (self.callerId.length)
connectParams[@"callerId"] = self.callerId;
connectParams[@"recording"] = @true;
self.activeConnection = [self.phoneDevice connect:connectParams delegate:self];
if ([self.delegate respondsToSelector:@selector(callStartedWithParams:incoming:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.delegate callStartedWithParams:connectParams incoming:NO];
});
}
}
这是我们在服务器端用php编写的代码:
$from = $_REQUEST['From'];
$callee = $_REQUEST['callee'];
$callerId = $_REQUEST['callerId'];
$digits = $_REQUEST['Digits'];
$record = (isset($_REQUEST["recording"]) && $_REQUEST["recording"] == true) ? " record='record-from-answer'" : '';
if (isset($digits) && !$callee) {
$callee = $_REQUEST[$digits];
}
$response = '<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial'.$record.' callerId="'.$callerId.'">
<Number url="http://ourserverurl.net/phoneRecorder/twilio/twilio-client-server-master/notification.php">'.$callee.'</Number>
</Dial>
</Response>';
【问题讨论】:
标签: ios twilio phone-call recording