react-native-webrtc / react-native-webrtc/react-native-callkeep
'answerCall' Listener occasionally does not run, when answering call while app is terminated/background
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 511
- Avg merge
- 9h 12m
- Merged PRs (30d)
- 2
Description
'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;
}, []);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the RNCallKeep.addEventListener('answerCall', pickupCall) registration and the useEffect that initializes it. Reproduce the issue while the app is terminated or in the background, then trace whether answerCall is delivered before registration; done means the event is reliably handled or its startup behavior is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100