question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'answerCall' Listener occasionally does not run, when answering call while app is terminated/background

See original GitHub issue

‘runs pickup’ is never logged to console. I suspect the ‘answerCall’ event occurs before listener is added in some cases. How do you check if app loaded with ‘answerCall’ event. As opposed to detecting an event in real time?

IE If ‘answerCall’ has already occured, then after you add the event listener: RNCallKeep.addEventListener(‘answerCall’, pickupCall), the function will instantly run. Or a way to check if ‘answerCall’ has already occurred when app starts?

Current code:

  // Picks up and accepts incoming call.
  const pickupCall = async () => {
    console.warn('runs pickup'); // <--------- Sometimes Never Runs
    setOpenCall({ recipient: {}, inCall: true, isIncomingCall: true });
    const id = oneTimeId();
    // Tell callkeep that call has begun
    RNCallKeep.setCurrentCallActive(id);

    // Relay that phone has been picked up
    // Just incase this function runs before 'onCallListener'
    // If it runs before 'sess.current' will not be the real session
    // So methods below will not do anything.
    pickedUp.current = true;

    // onRemoteStreamListener event gets registered if both phones run this function
    const stream = await sess.current?.getUserMedia?.(MEDIA_OPTIONS);
    // The function to cause the call to be connected
    await sess.current?.accept?.({});
    // Setting of localStream video and preparing the remote stream object for incoming remote stream
    setLocalStreams([{ userId: 'localStream', stream }]);
    setRemoteStreams([{ userId: sess.current.initiatorID, stream: null }]);
  };

  const callkeepListenersInit = async () => {
    console.warn('runs callkeep');
    RNCallKeep.setAvailable(true);
    RNCallKeep.addEventListener('answerCall', pickupCall);
    RNCallKeep.addEventListener('endCall', rejectCall);
  };

  // Removes all listeners when component unmounts.
  const cleanup = () => {
    RNCallKeep.removeEventListener('answerCall');
    RNCallKeep.removeEventListener('endCall');
    hangup();
  };

  // First mount hooks up all listeners.
  useEffect(() => {
    cubeListenersInit();
    callkeepListenersInit();
    return cleanup;
  }, []);

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

8reactions
classiebitcommented, Jun 9, 2021

Someone, please help! 🙏 answerCall event is not firing in Android only. When we call displayIncomingCall and the incoming call shows on Android, and when we press the call end button, the endCall event is firing, but when we press the call-accept button, it stays there on the call screen and nothing happens. And the answerCall event is not firing.

Please help, we’ve tried all the solutions, nothing is working.

1reaction
namnmcommented, Jan 13, 2021

I dont know much about your detail situation so I can not help.

About me, I handled that didLoadWithEvents as following: https://github.com/brekekesoftware/brekekephone/blob/master/src/utils/callkeep.ts#L62

Read more comments on GitHub >

github_iconTop Results From Across the Web

answerCall' CallKeep Listener occasionally does not ... - GitHub
answerCall' CallKeep Listener occasionally does not run, when answering call while app is terminated/background #517. Open. 2 of 3 tasks.
Read more >
answerCall' CallKeep Listener occasionally does not run ...
React Native CallKeep : answerCall' CallKeep Listener occasionally does not run, when answering call while app is terminated/background.
Read more >
[Solved]-React-Native: chat over voice-webrtc
As an alternative you can try ConnectyCube React Native video chat. ... Listener occasionally does not run, when answering call while app is...
Read more >
Unable To Answer Or See Incoming Calls On Motorola ...
Unable To Answer Or See Incoming Calls On Motorola Phones Easy FIX!! IN THIS VIDEO I WILL SHOW YOU HOW TO BRING BACK...
Read more >
reconnect-react-native-callkeep - npm
Tell ConnectionService that the device is ready to make outgoing calls via the native Phone app. If not the user will be stuck...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found