MrHertal / react-native-twilio-phone

Twilio Voice React Native module.
MIT License
154 stars 67 forks source link

When one user hangs up the call - the second one continues to run the call time. #44

Closed theol93 closed 2 years ago

theol93 commented 3 years ago

Hello, I have a problem when making calls between two users when one hangs up the second one continues to run the call time. How can you make the receiver go down as well as with usual phone calls?

on the js side this code does not give the expected behavior

function hangup() { RNCallKeep.endAllCalls(); setCallInProgress(false); }

/make-call

exports.handler = function(context, event, callback) {
  const from = 'client:'+event.from;
  const twiml = new Twilio.twiml.VoiceResponse();

  var to = event.to;
    if (!to) {
      twiml.say('Congratulations! You have made your first call! Good bye.');
    } else {
      const dial = twiml.dial({callerId : from, action: '/hangup', method: 'POST'});
      dial.client(to);
    }
    callback(null, twiml);
};

an attempt to redirect a function from the server to a TwiML does not bring any result either

/hangup

exports.handler = function(context, event, callback) {
    const twiml = new Twilio.twiml.VoiceResponse();
    twiml.hangup();
    callback(null, twiml);
}
MrHertal commented 3 years ago

Hi,

What versions of CallKeep, Firebase Messaging and VoIP Push Notification are you using ?

theol93 commented 3 years ago

Hi, im use the latest:

"react-native-callkeep": "^4.2.0",
"react-native-voip-push-notification": "^3.3.0",
"@react-native-firebase/messaging": "^12.0.0"

on the versions recommended by you in the example, the situation is the same, but just in case I will double-check and write the result here tomorrow

theol93 commented 3 years ago
    "@react-native-firebase/app": "^11.5.0",
    "@react-native-firebase/messaging": "^11.5.0",
    "react-native-callkeep": "^4.0.1",
    "react-native-voip-push-notification": "^3.1.0"

still on the other side do not hang up at the end of the call

MrHertal commented 3 years ago

Hi, sorry the documentation is confusing (I shall update it soon).

Try with the exact versions:

"@react-native-firebase/app": "11.5.0", "@react-native-firebase/messaging": "11.5.0", "react-native-callkeep": "4.0.1", "react-native-voip-push-notification": "3.1.0"

I did not test this library with latest versions.

If it still doesn't work, try to reproduce the bug with the example app.

theol93 commented 3 years ago

So I did some research and determined that listener subscriptions do not work for me, since I separated the logic in the application as early as possible, I receive a token, initialize RNTwilioPhone and subscribe to listeners (logs do not work here) to receive calls when the application is minimized / killed.

I make calls from another page intended for calls, because I cannot launch the application from this page (i need other initial page).

Trying to fix this, I moved the listener subscriptions inside the call page and this is what I got:

 ios call to android => android hangup via CallKeep (success)
 ios call to android => android hangup via App (success)
 ios call to android => ios hangup via App (fail)
 android call to ios => ios hangup via CallKeep (success)
 android call to ios => ios hangup via APP (success)
 android call to ios => android hangup via CallKeep (fail)

In any case, I can only cancel the call from the device to which we are calling. From the device from which I am calling, I cannot cancel the call even if it has not yet reached the addressee and I canceled it, the addressee will still receive it and can answer with sound.

I need help with canceling a call and moving the subscription logic up in the application to successfully receive a call when the application is not active.

Do you have any ideas?

PS: Update. I have tested the calls when subscribing listeners in my call component they work fine. I only need to fix the calls so that each participant in the conversation can successfully cancel the call for both

theol93 commented 3 years ago

Hi, Twilio phone example has the same problems, I also tried native Voice Quickstart for Objective-C from Twilio docs and they work as expected. Unfortunately I do not know well obj-c enough to find the difference and the problem.

MrHertal commented 3 years ago

Hi,

I will try to reproduce on the example app when I find some time.

MrHertal commented 2 years ago

Sorry I could not reproduce.

saurabh874 commented 2 years ago

@MrHertal I am also facing same issue If during the call, the app is killed from the background, the call does not get ended from customer's end.