react-native-twilio-programmable-voice
react-native-twilio-programmable-voice copied to clipboard
Android: can't get custom parameters from Twilio on "deviceDidReceiveIncoming"
Using:
- React Native: 0.63.2
- react-native-twilio-programmable-voice 4.3.0
- Android 10 Samsumg
On "deviceDidReceiveIncoming" event, I expect to get custom parameters from Twilio but I have only 3 parameters: "call_sid", "call_from", "call_to".
This is how the PHP backend sends extra parameters:
$response = new VoiceResponse();
$dial = $response->dial(null, ['callerId'=>"+1$caller"]);
$client = $dial->client();
$client->identity($to);
$client->parameter(array('name' => 'location', 'value' => $location));
$client->parameter(array('name' => 'caller' , 'value' => $callerMsg));
$client->parameter(array('name' => 'soList' , 'value' => json_encode($soList)));
And I have a website that receives these parameters correctly.
device.on('incoming', function(connection) {
console.log('Twilio incoming');
var customInfo = Helper.MapToObj(connection.customParameters);
// {
// "location": "",
// "caller": "",
// "soList": ""
// }
});
Is there a way I can get extra parameters in "deviceDidReceiveIncoming"? Or is this something I need to do in "TwilioVoiceModule.java" file?
Is anyone here to review my issue?
Hi @mevanso01 my apologies for the late reply!
This might be possible with some additional plugin. I will add this a feature request. In essence, we already have it built in but just not passing on the custom parameters to React.
See this PR: https://github.com/hoxfon/react-native-twilio-programmable-voice/pull/170/files
If somebody has time to put in the work and expose the custom params to react then your issue will be solved. Until then I mark this as 'in backlog'.
Hi @jdegger thanks for your reply.
I was able to modify the Android source code of this package for my need and it works well. https://github.com/mevanso01/rn-gma-twilio-programmable-voice/commit/11e6b2edd75ad8ccaf026c0d0a87690ca4523605
@mevanso01 thats great! Would you be willing to PR this? Of course that would also need the iOS work done but that would amazing.
Let me know
@jdegger sure, I will. What're the steps to do that?
By the way, is this possible for iOS? TwilioVoice works through iOS CallKit, so I think sending custom parameters are for Android only. https://support.twilio.com/hc/en-us/articles/115011213347-Passing-Custom-Information-via-Requests-to-Twilio
What do you think?
Hi @mevanso01 I think the solution is in your own URL you posted:

callInvite.customParameters