【问题标题】:Call recording using twilio in iOS application在 iOS 应用程序中使用 twilio 进行通话录音
【发布时间】: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


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    您可以使用connectParamspass parameters to the TwiML application。您传递的任何参数都将传递给您的 PHP 应用程序。因此,您可以添加一个参数来表示您是否正在录制,然后生成将录制或不录制的 TwiML。

    例如:

    NSMutableDictionary *connectParams = [NSMutableDictionary dictionaryWithDictionary:params];
        if (callee.length)
            connectParams[@"callee"] = callee;
        if (self.callerId.length)
            connectParams[@"callerId"] = self.callerId;
        if (self.recording)
            connectParams[@"recording"] = @true;
    

    然后在你的 PHP 中:

    <?php 
    
    $recording = isset($_REQUEST["recording"]);
    
    $response = "<Response>"
    $response .= "<Dial";
    if ($recording) {
      $response .= " record='record-from-answer'";
    }
    $response .= "><Number>+15551234567</Number></Dial></Response>";
    
    header("Content-Type: text/xml");
    echo $response;
    

    当然,你可能也在设置其他值,这是获取录制参数和using it with TwiML to record the call的示例。

    【讨论】:

    • 我们在服务器端用 php 编写了相同的代码,但我们的 php 代码中没有记录参数。在 iOS 端,我们编写了相同的代码并发起了调用。除了您提供的解决方案中提到的以外,是否还有其他设置需要完成。
    • 我们接收到callee和callerId,但是php中没有接收到录音参数。
    • 您可以编辑您的问题并分享使用这些参数进行调用的函数吗?为了提供帮助,我需要多看一点。
    • 抱歉,我指的是 Objective-C 方面的东西,尽管 PHP 会有所帮助。
    • 啊,好的。所以,说实话,我不是一个强大的 PHP 开发人员。你能看到$_REQUEST["recording"] 是否被设置,看看它被设置成什么吗?我不知道它是否会以字符串而不是布尔值的形式出现(尽管我怀疑它可能是字符串,因此您与 true 的比较可能不起作用)。
    【解决方案2】:

    Twilio 客户支持在这里。

    我在对您的 Web 应用程序的 HTTP 请求中没有看到参数“记录”。这意味着它不是由 iOS 应用发送的。

    -- 罗伯

    【讨论】:

    • 我可以用twillio制作一个iOS应用来记录电话吗?如是。你能引导我走向正确的方向吗?是否还需要后端服务器。需要a - z的详细信息,请
    猜你喜欢
    • 1970-01-01
    • 2014-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-14
    • 2023-04-09
    • 1970-01-01
    相关资源
    最近更新 更多