如何在 iOS 上为 Twilio TVOCallInvite 设置自定义参数?
How do I set custom parameters for Twilio TVOCallInvite on iOS?
我正在尝试在呼叫邀请结构中传递自定义参数,但在接收方未收到它们。
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)
有什么想法吗?
实际上放弃了这个想法...按照这个 instruction 以便应用报告对 CallKit 的呼叫,然后更新呼叫者姓名。
您需要在后端添加逻辑,或者您可以说出相同的服务器代码。
Link 用于节点中的服务器代码
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
变量创建 var 而不是 const,并且如果您要传递调用者姓名,则节点代码格式应以此格式保存值
'client:callername'
即client:
之后是从 iOS 应用程序
传递的值
我正在尝试在呼叫邀请结构中传递自定义参数,但在接收方未收到它们。
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)
有什么想法吗?
实际上放弃了这个想法...按照这个 instruction 以便应用报告对 CallKit 的呼叫,然后更新呼叫者姓名。
您需要在后端添加逻辑,或者您可以说出相同的服务器代码。
Link 用于节点中的服务器代码 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
变量创建 var 而不是 const,并且如果您要传递调用者姓名,则节点代码格式应以此格式保存值
'client:callername'
即client:
之后是从 iOS 应用程序