Coder Social home page Coder Social logo

Comments (4)

dolsem avatar dolsem commented on June 3, 2024

I'm having the same issue on iOS. Sometimes endAllCalls works properly, and sometimes it doesn't

from react-native-twilio-phone.

2DTW avatar 2DTW commented on June 3, 2024

@dolsem @bradydoll You need to set the callSid in your Call Connected listener. Then in your hangup function, add TwilioPhone.endCall(callSid).

Something like this:

  const [callSid, setCallSid] = useState('')
  const [to, setTo] = React.useState('');
  const [callInProgress, setCallInProgress] = React.useState(false);
  RNTwilioPhone.handleBackgroundState(callKeepOptions);


  React.useEffect(() => {
    return RNTwilioPhone.initialize(callKeepOptions, fetchAccessToken);
  }, []);


  React.useEffect(() => {
    const subscriptions = [
      twilioPhoneEmitter.addListener(EventType.CallConnected, ({callSid}) => {
        setCallSid(callSid)
        setCallInProgress(true);
      }),
      twilioPhoneEmitter.addListener(EventType.CallDisconnected, () => {
        setCallInProgress(RNTwilioPhone.calls.length > 0);
        RNCallKeep.endAllCalls();


      }),
      twilioPhoneEmitter.addListener(
        EventType.CallDisconnectedError,
        (data) => {
          console.log(data);
          setCallInProgress(RNTwilioPhone.calls.length > 0);
          RNCallKeep.endAllCalls();
        }
      ),
    ];


    return () => {
      subscriptions.map((subscription) => {
        subscription.remove();
      });
    };
  }, []);


  function hangup() {
    TwilioPhone.endCall(callSid);
    RNCallKeep.endAllCalls();
    setCallInProgress(RNTwilioPhone.calls.length > 0);
  }

from react-native-twilio-phone.

bradydoll avatar bradydoll commented on June 3, 2024

@2DTW Isn't calling TwilioPhone.endCall() handled by this library?

In /src/RNTwilioPhone.ts there is a listener for the RNCallKeep 'endCall' event that calls it:

    RNCallKeep.addEventListener('endCall', ({ callUUID }) => {
      const sid = RNTwilioPhone.getCallSid(callUUID);

      sid && TwilioPhone.endCall(sid);

      RNTwilioPhone.removeCall(callUUID);
    });

After re-trying the example app, hangup is working for me now. I'm not sure what is different with my initial testing that was causing the issue.

from react-native-twilio-phone.

nguyentuanit97 avatar nguyentuanit97 commented on June 3, 2024

@bradydoll the root cause because the funtions RNTwilioPhone.getCallSid(callUUID) not working when your app killed. It mean it's only working when app is live or background. I face this issue now.

from react-native-twilio-phone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.