react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
909 stars 438 forks source link

Route incoming call #788

Open nitishymtpl opened 3 months ago

nitishymtpl commented 3 months ago

Hello guys,

I want to forward my incoming call to SIP URI e.g Sip:user@demo.com. How to achieve it?

Thanks

Irfanwani commented 3 months ago

I am not sure, i am also trying to achieve something similar, but here is how i am trying it. when using sip, we get an invite when someone calls us which we can handle using onInvite delegate of useragent. That is passed with the invitation object which is the main thing.

Here is react-native-callkeep, we can use listeners to check if the call is answered or rejected or any other action is taken like this:

RNCallKeep.addEventListener('answerCall', onAnswerCall);
RNCallKeep.addEventListener('endCall', onEndCall);

Then, we need to have access to the invitation object from sip and inside the onAnswerCAll function, we can call, invitation.accept() to accept the call and so on.

nitishymtpl commented 3 months ago

Hey, Did you checked it? Is it working?

On Fri, Jun 28, 2024, 9:49 PM Irfan Wani @.***> wrote:

I am not sure, i am also trying to achieve something similar, but here is how i am trying it. when using sip, we get an invite when someone calls us which we can handle using onInvite delegate of useragent. That is passed with the invitation object which is the main thing.

Here is react-native-callkeep, we can use listeners to check if the call is answered or rejected or any other action is taken like this:

RNCallKeep.addEventListener('answerCall', onAnswerCall); RNCallKeep.addEventListener('endCall', onEndCall);

Then, we need to have access to the invitation object from sip and inside the onAnswerCAll function, we can call, invitation.accept() to accept the call and so on.

— Reply to this email directly, view it on GitHub https://github.com/react-native-webrtc/react-native-callkeep/issues/788#issuecomment-2196833633, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ5AHJNVCGIQKLFCCN37D5LZJVLXPAVCNFSM6AAAAABJLJM5SKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWHAZTGNRTGM . You are receiving this because you authored the thread.Message ID: @.*** com>

Irfanwani commented 3 months ago

If you are talking about the listeners, yes it is working now, still working on the sip part.

nitishymtpl commented 3 months ago

Hi Irfan, Do you updated github repo, which could I look into ? Would you mind sharing it. I'll also give a try :).

On Sun, Jun 30, 2024, 8:55 PM Irfan Wani @.***> wrote:

yes it is working now

— Reply to this email directly, view it on GitHub https://github.com/react-native-webrtc/react-native-callkeep/issues/788#issuecomment-2198536709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ5AHJJ55KKVNL7ZQCGRPADZJ7W4HAVCNFSM6AAAAABJLJM5SKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGUZTMNZQHE . You are receiving this because you authored the thread.Message ID: @.*** com>

Irfanwani commented 3 months ago

Sorry, I was just talking about the listeners. But talking about the SIP part, here is the flow, You need to set the listeners for callkeep so that whenever a user interacts with the call buttons i.e, either accepts the call or rejects it (or similarly we have other listeners too like when a user toggles mute etc), the call back function should handle the rest. For that, inside the callback functions provided to listeners, you should have access to the invitation object coming from onInvite method of user agent delegate. The, you just need to call accept or reject in the callback functions accordingly.

Irfanwani commented 2 months ago

I tested the listeners in foreground and it works, but not when the app is killed. Also, when answering the call, call accepted screen is never shown, it just shows a blank screen and then after some time shows the incoming call UI again.