hoxfon / react-native-twilio-programmable-voice

React Native wrapper for Twilio Programmable Voice SDK
MIT License
181 stars 152 forks source link

Android: can't get custom parameters from Twilio on "deviceDidReceiveIncoming" #181

Open mevanso01 opened 3 years ago

mevanso01 commented 3 years ago

Using:

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?

mevanso01 commented 3 years ago

Is anyone here to review my issue?

jdegger commented 3 years ago

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'.

mevanso01 commented 3 years ago

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

jdegger commented 3 years ago

@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

mevanso01 commented 3 years ago

@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?

jdegger commented 3 years ago

Hi @mevanso01 I think the solution is in your own URL you posted:

image

callInvite.customParameters