【问题标题】:How do I set custom parameters for Twilio TVOCallInvite on iOS?如何在 iOS 上为 Twilio TVOCallInvite 设置自定义参数?
【发布时间】:2019-11-06 05:28:21
【问题描述】:

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

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)

有什么想法吗?

【问题讨论】:

    标签: ios swift twilio twilio-api twilio-twiml


    【解决方案1】:

    您需要在后端添加逻辑,或者您可以说服务器代码。

    节点中服务器代码的链接 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,如果您传递调用者名称,则节点代码格式应该以这种格式保存值

    'client:callername'
    

    client: 之后是从 iOS 应用程序传递的值

    【讨论】:

      【解决方案2】:

      实际上已经放弃了这个想法...跟随这个instruction,以便应用程序报告对 CallKit 的调用,然后在此之后更新调用者姓名。

      【讨论】:

        猜你喜欢
        • 2020-10-24
        • 1970-01-01
        • 2013-03-30
        • 2020-08-27
        • 1970-01-01
        • 1970-01-01
        • 2017-11-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多