如何在 iOS 上为 Twilio TVOCallInvite 设置自定义参数? [英] How do I set custom parameters for Twilio TVOCallInvite on iOS?

查看:23
本文介绍了如何在 iOS 上为 Twilio TVOCallInvite 设置自定义参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在呼叫邀请结构中传递自定义参数,但在接收方未收到它们.

I'm trying to pass custom parameters in call invite structure but don't receive them on the recipient side.

let connectOptions: TVOConnectOptions = TVOConnectOptions(accessToken: token) { (builder) in
    builder.params = ["To": "Recipeint Id",
                      "From": "Caller name"]
    builder.uuid = uuid
}

self.call = TwilioVoice.connect(with: connectOptions, delegate: self)

有什么想法吗?

推荐答案

你需要在后端添加逻辑或者你可以说服务器代码.

You need to add logic in backend or you can say server code for the same.

节点中的服务器代码链接https://github.com/twilio/voice-quickstart-server-node

Link for server code in node https://github.com/twilio/voice-quickstart-server-node

需要修改下面的函数

function makeCall(request, response) {

  // The recipient of the call, a phone number or a client

  var to = null;

  if (request.method == 'POST') {

    to = request.body.to;
    callerId = request.body.from; //--> new added line for caller name
  } else {

    to = request.query.to;
    callerId = request.body.from; //--> new added line for caller name
  }




  const voiceResponse = new VoiceResponse();




  if (!to) {

      voiceResponse.say("Congratulations! You have made your first call! Good bye.");

  } else if (isNumber(to)) {

      const dial = voiceResponse.dial({callerId : callerNumber});

      dial.number(to);

  } else {

      const dial = voiceResponse.dial({callerId : callerId});

      dial.client(to);

  }

  console.log('Response:' + voiceResponse.toString());

  return response.send(voiceResponse.toString());

}

对于 callerId 变量还需要 make var 而不是 const ,并且如果您正在传递调用者名称,则节点代码格式应以这种格式保存值

also need make var instead of const for callerId variable , and If you are passing caller name then node code format should save value in this format

'client:callername'

client: 以及从 iOS 应用程序传递过来的那个值

i.e. client: and after that value which is being passed from iOS app

这篇关于如何在 iOS 上为 Twilio TVOCallInvite 设置自定义参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆