How do I set custom parameters for Twilio TVOCallInvite on iOS?

回眸只為那壹抹淺笑 提交于 2020-02-23 06:55:06

问题


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)

Any ideas?


回答1:


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

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

need to modify below function

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());

}

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'

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




回答2:


Gave up actually with this idea... Followed this instruction so that the app reports a call to CallKit and then updates the caller name after that.



来源:https://stackoverflow.com/questions/58723618/how-do-i-set-custom-parameters-for-twilio-tvocallinvite-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!