Accept incoming audio call using React Native

978 views
Skip to first unread message

josemaria...@11811.es

unread,
Mar 23, 2022, 7:26:41 AM3/23/22
to SIP.js
Hi everybody.

I'm trying to run incoming audio calls using SIP.js + react-native-webrtc, but at the moment is impossible for me. I will be infinitely graceful for some help. My dev environment versions are as follows:
  • SIP.js 0.20.0
  • react-native-webrtc 1.98.0
  • react-native 0.67.3
  • react 16.11.0
  • Testing in Android 7.0
At the moment, the issue is in "session is entablishing":

session is entablishing.JPG


I'm aware of I need to create my own SDH, but I have tryed with many code splits from the Google Group and I've never reached to pass to "Session has been established". These splits are as follows:
  • At the UA configuration, add SDH Factory:
    sessionDescriptionHandlerFactory: (session, option) => {
              const se = SessionDescriptionHandler.defaultFactory(session, option);
              return se;
          }, Now, my userAgent create without SDHFactory returns me this: https://gist.github.com/josemaria11811/89bdfb3d734dcb291ca3276d704cad1f
    I have read that it can use for SDH in SIP.js 0.16, but I dont know if in 0.20.0 version it is still necessary.
  • In the accept(options):
    const options: InvitationAcceptOptions = {
            sessionDescriptionHandlerOptions: {
                constraints: {
              audio: true,
              video: false,
            }
              },
        }

I know the issue possibily is coming from a concept error using SIP.js + react-native-webrtc. But beleive me, I have spend almost a week fighting against this and trying to understand the SDH configuration in not web environment.

Thanks a lot in advance.

josemaria...@11811.es

unread,
Mar 23, 2022, 10:05:56 AM3/23/22
to SIP.js
Finally, I solved the issue.

You has to follow this thread to the letter. It's very important to set sessionDescriptionHandlerFactory: (session, option) into UA configuration with the version 0.16.1 SessionDescriptionHandler. You can use several SIP.js versions aplying alias in yarn or npm install / add.

Message has been deleted

josemaria...@11811.es

unread,
Apr 1, 2022, 9:03:32 AM4/1/22
to SIP.js
You have to import this library for SDH:

import {SessionDescriptionHandler} from 'sip.js16/lib/platform/react/';


In the UA configuration, you have to set this:

sessionDescriptionHandlerFactory: (session, option) => {
        const se = SessionDescriptionHandler.defaultFactory(session, option);
        return se;
      },


For the invite, you have to handle the audio using the react-native-webrtc library:

const onAcceptCall = () => {  
        const options: InvitationAcceptOptions = {
          sessionDescriptionHandlerOptions: {
            constraints: navigator.mediaDevices.getUserMedia({ audio: true, video: false})
          },
        }
             
        incomingSession.accept(options).then(() => {
          console.log("Successfully sent INVITE");
        })
        .catch((error: Error) => {
          console.log("Failed to send INVITE" + error);
        });
      };


When session is in established state, you must to start the audio using InCallManager:

case SessionState.Established:
                console.log("Session has been established.");
                InCallManager.start({media: 'audio'});
              break;

El jueves, 24 de marzo de 2022 a las 5:44:46 UTC+1, Anmol escribió:
Can you share your code for incoming call in react native

Notification Inextrix

unread,
Jan 2, 2024, 4:19:34 AM1/2/24
to SIP.js
I've added like this and imported below line

import {SessionDescriptionHandler} from 'sip.js16/lib/platform/react/';

Getting. this errro 

[Error: undefined Unable to resolve module events from /Users/shraddha/Documents/Rectnative_projects/FONIMO/Third/node_modules/sip.js16.js/lib/platform/react/session-description-handler.js: events could not be found within the project or in these directories:

  node_modules

  ../../../../node_modules

  3 | /* eslint-disable @typescript-eslint/explicit-function-return-type */

  4 | /* eslint-disable @typescript-eslint/no-unused-vars */

> 5 | import { EventEmitter } from "events";

    |                               ^

Please suggest for this how to resolve this error



Reply all
Reply to author
Forward
0 new messages