Giter Club home page Giter Club logo

react-native-sip's Introduction

react-native-sip

npm version

UPDATE: Now is compatible with RN 0.60+ (iOS and AndroidX)

iOS - For RN 0.60+ you need to execute the following commands:

yarn add react-native-sip
cd ios
pod install

Support

  • Currently support for iOS and Android.
  • Support video and audio communication.
  • Ability to use Callkit and PushNotifications.
  • You can use it to build an iOS/Android app that can communicate with SIP server.
  • Android version is based on react-native-pjsip-builder
  • iOS version is based on Vialer-pjsip-iOS

To do

  • Send SIP Messages (IM) iOS
  • Send SIP Messages (IM) Android
  • isTyping iOS
  • isTyping Android

Installation

Usage

First of all you have to initialize module to be able to work with it.

There are some interesting moment in initialization. When application goes to background, sip module is still working and able to receive calls, but your javascipt is totally suspended. When User open your application, javascript start to work and now your js application need to know what status have your account or may be you have pending incoming call.

So thats why first step should call start method for sip module.

import {Endpoint} from 'react-native-sip'

let endpoint = new Endpoint();
let state = await endpoint.start(); // List of available accounts and calls when RN context is started, could not be empty because Background service is working on Android
let {accounts, calls, settings, connectivity} = state;

// Subscribe to endpoint events
endpoint.on("registration_changed", (account) => {});
endpoint.on("connectivity_changed", (online) => {});
endpoint.on("call_received", (call) => {});
endpoint.on("call_changed", (call) => {});
endpoint.on("call_terminated", (call) => {});
endpoint.on("call_screen_locked", (call) => {}); // Android only

Account creating is pretty strainghforward.

let configuration = {
  "name": "John",
  "username": "sip_username",
  "domain": "pbx.carusto.com",
  "password": "****",
  "proxy": null,
  "transport": null, // Default TCP
  "regServer": null, // Default wildcard
  "regTimeout": null // Default 3600
  "regHeaders": {
    "X-Custom-Header": "Value"
  },
  "regContactParams": ";unique-device-token-id=XXXXXXXXX"
};
endpoint.createAccount().then((account) => {
  console.log("Account created", account);
});

To be able to make a call first of all you should createAccount, and pass account instance into Endpoint.makeCall function. This function will return a promise that will be resolved when sip initializes the call.

let options = {
  headers: {
    "P-Assserted-Identity": "Header example",
    "X-UA": "React native"
  }
}

let call = await endpoint.makeCall(account, destination, options);
call.getId() // Use this id to detect changes and make actions

endpoint.addListener("call_changed", (newCall) => {
  if (call.getId() === newCall.getId()) {
     // Our call changed, do smth.
  }
}
endpoint.addListener("call_terminated", (newCall) => {
  if (call.getId() === newCall.getId()) {
     // Our call terminated
  }
}

API

DOCUMENTATION

This repo it's based on a fork of datso/react-native-pjsip.

react-native-sip's People

Contributors

akolpakov avatar cmendes0101 avatar datso avatar florindumitru avatar jojonarte avatar mdiflorio avatar rodrigowbazevedo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-sip's Issues

How to detect if destination has answer the call

when making a call to some destination, how can i detect if destination has answer the call.
i get PJSIP_INV_STATE_CONFIRMED when call start but state didn't change when destination has answer the call

I am not able to create a new account

Screenshot_2020-08-05 Screenshot from 2020-08-05 21-40-21 png (PNG Image, 1600 × 900 pixels) - Scaled (83%)
I am not able to create a new account. Getting promise rejection.

this is my code to add an account......
const contactUriParams = Platform.select({
// ios: [
// ";app-id=com.carusto.mobile.app",
// (tokens['voip'] ? ;pn-voip-tok=${tokens['voip']} : ""),
// (tokens['im'] ? ;pn-im-tok=${tokens['im']} : "")
// ].join(""),
// android: ;im-type=sip,
// })

// const account = await endpoint.createAccount({
//   ...configuration,
//   transport: configuration.transport ? configuration.transport : "UDP",
//   contactUriParams
// })
// console.log('account',account)

Send Sip (IM) Messages !

  • iOS implementation it's done !
  • Android soon

Usage

endpoint.sendMessage(account, destinationURI, message);

İ cant use wifi for calling.

Hi bro i have some problem about calling someone with wifi network.

When i use mobile data i can all anyone i want with sip library but when i try to call someone using wifi network. just my account not loggining on Interactive Voice Response. Is there any fix i can use it ?

What about windows/mac ?

Since 0.61.5 react-native release we are able to develop for windows 10 and macos , it'd be possible to have this module working on one of those OS ?

Echo cancellation

Hi,

Is echo cancellation added to this library? In speaker mode we could hear echo for our calls.

Does not register when using a proxy ("INVALID URI")

Our pbx uses a proxy and when I put in the proxy, it throws an error saying "INVALID URI".

"proxy": "proxy.mypbx.com",

If I use proxy: "proxy.mypbx.com:5060", the error changes to "INVALID URI SCHEME"

Please note that these settings work in third party sip phone app.

Also, the app works fine without the proxy.

[Android 9+] Microphone audio stream ends after 1 min of talk in background

On Android 9+, after going to background mode, when being in active call, the stream from microphone is being cut after 1 minute of talking. When moving back to foreground, the stream becomes active again.
My research showed that Android 9+ has this behavior for apps for security reasons.
https://developer.android.com/guide/topics/media/mediarecorder

Note: On devices running Android 9 (API level 28) or higher, apps running in the background cannot access the microphone. Therefore, your app should record audio only when it's in the foreground or when you include an instance of MediaRecorder in a foreground service.

To prevent this, a FOREGROUND SERVICE must be started for a process, that uses a microphone (with static ongoing notification like "this app is using microphone in background. Google Meets, Hangouts and WhatsApp have the same behavior). Have anybody tried this ? How can pjsib be started inside a foreground service? I am new to Java and android architecture in general, so any help will be highly appreciated
Many thanks in advance.

Adjust volume via System / User Interface - iOS

Hey guys.
Thanks for such a great package.
Found how to programmatically set the "RX" (Receiving) volume on iOS but would love to give the user the option to adjust this based on the system volume level.

This is the API that appears to change the receiving volume
pjsua_conf_adjust_rx_level(info.conf_slot, <0-255>);

Is there a way to interface the volume with the system set volume level?

Install error (url not found)

Looking the log seems it try to download http://www.pjsip.org/release/2.7.1/pjproject-2.7.1.tar.bz2 but it's not found. Can you fix it?

1381 verbose Darwin 20.5.0
1382 verbose argv "/usr/local/Cellar/node/16.1.0/bin/node" "/usr/local/bin/npm" "install"
1383 verbose node v16.1.0
1384 verbose npm  v7.11.2
1385 error code 1
1386 error git dep preparation failed
1387 error command /usr/local/Cellar/node/16.1.0/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/dario/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
1388 error > [email protected] postinstall
1388 error > bash libs.sh
1389 error npm WARN using --force Recommended protections disabled.
1389 error npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
1389 error npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
1389 error npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
1389 error npm WARN deprecated [email protected]: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
1389 error npm WARN deprecated [email protected]: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
1389 error npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
1389 error npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
1389 error npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
1389 error npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
1389 error x react-native-pjsip-builder-2.8.0/
1389 error x react-native-pjsip-builder-2.8.0/.gitignore
1389 error x react-native-pjsip-builder-2.8.0/LICENSE
1389 error x react-native-pjsip-builder-2.8.0/README.md
1389 error x react-native-pjsip-builder-2.8.0/android/
1389 error x react-native-pjsip-builder-2.8.0/android/Dockerfile
1389 error x react-native-pjsip-builder-2.8.0/android/build_openh264.sh
1389 error x react-native-pjsip-builder-2.8.0/android/build_openssl.sh
1389 error x react-native-pjsip-builder-2.8.0/android/build_opus.sh
1389 error x react-native-pjsip-builder-2.8.0/android/build_pjsip.sh
1389 error x react-native-pjsip-builder-2.8.0/build_android.sh
1389 error x react-native-pjsip-builder-2.8.0/build_ios.sh
1389 error x react-native-pjsip-builder-2.8.0/ios/
1389 error x react-native-pjsip-builder-2.8.0/ios/Dockerfile
1389 error x react-native-pjsip-builder-2.8.0/release.sh
1389 error #1 [internal] load build definition from Dockerfile
1389 error #1 sha256:9614faabd47f56c52f90aa6f14ac035eec6102dfafbaf0e708fb548cf669fbf0
1389 error #1 transferring dockerfile: 37B done
1389 error #1 DONE 0.0s
1389 error
1389 error #2 [internal] load .dockerignore
1389 error #2 sha256:c790b927830b84f0de6166afde08d045b24cb89b4bc1661de133adf3736790e6
1389 error #2 transferring context: 2B done
1389 error #2 DONE 0.0s
1389 error
1389 error #3 [internal] load metadata for docker.io/library/ubuntu:latest
1389 error #3 sha256:8c6bdfb121a69744f11ffa1fedfc68ec20085c2dcce567aac97a3ff72e53502d
1389 error #3 DONE 1.2s
1389 error
1389 error #4 [ 1/24] FROM docker.io/library/ubuntu:latest@sha256:aba80b77e27148d99c034a987e7da3a287ed455390352663418c0f2ed40417fe
1389 error #4 sha256:c98a3991d315ab7147ab92247ee913d209f36dce985342ae1a871ab6d55f6450
1389 error #4 DONE 0.0s
1389 error
1389 error #5 [ 2/24] RUN dpkg --add-architecture i386 &&     apt-get -y upgrade &&     apt-get -y dist-upgrade &&     apt-get update
1389 error #5 sha256:25e8979757749e05d6f2b787ac642da191e2abcf9a65351d9b932153b4197e3a
1389 error #5 CACHED
1389 error
1389 error #9 [ 6/24] RUN cd /sources/android_sdk &&     curl -L -# -o sdk.zip "https://dl.google.com/android/repository/tools_r25.2.5-linux.zip" &&     unzip sdk.zip
1389 error #9 sha256:378795ff05a7967f1f984c9d9c523e446b0c02d49bf96106b73e2980539b8925
1389 error #9 CACHED
1389 error
1389 error #6 [ 3/24] RUN DEBIAN_FRONTEND=noninteractive apt-get -y install     software-properties-common git curl bzip2 gcc g++ binutils make autoconf openssl     libssl-dev ant libopus0 libpcre3 libpcre3-dev build-essential nasm libc6:i386 libstdc++6:i386 zlib1g:i386     openjdk-8-jdk unzip
1389 error #6 sha256:d509ba93d5bf18f16d890aa984042574875cb31b02ee74917210c040701e9d8f
1389 error #6 CACHED
1389 error
1389 error #8 [ 5/24] RUN cd /sources/android_ndk && 	curl -L -# -o ndk.zip "https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip" &&     unzip ndk.zip &&     rm -rf ndk.zip &&     mv android-*/* ./
1389 error #8 sha256:13eda312808e1e6b89f6327bc431374f1d2507801209aeae7f341d3982a11d1a
1389 error #8 CACHED
1389 error
1389 error #7 [ 4/24] RUN mkdir -p /sources/android_ndk &&     mkdir -p /sources/android_sdk &&     mkdir -p /sources/pjsip &&     mkdir -p /sources/swig &&     mkdir -p /sources/openssl &&     mkdir -p /sources/opus &&     mkdir -p /sources/openh264
1389 error #7 sha256:d1c7f955026fe97b8ea979759ff1e6b4d8bbe051896ed34f18fec3b2d548009f
1389 error #7 CACHED
1389 error
1389 error #10 [ 7/24] RUN cd /sources/android_sdk/tools &&     ALL_SDK=$(./android list sdk --all) &&     IFS=" " &&     for api in 23 25;     do       PACKAGE=$(echo "${ALL_SDK}" | grep "API ${api}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1);       echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force;     done &&     PACKAGE=$(echo "${ALL_SDK}" | grep "Android SDK Platform-tools" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1) &&     echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force &&     PACKAGE=$(echo "${ALL_SDK}" | grep "Build-tools" | grep "${BUILD_TOOLS_VERSION}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1) &&     echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force
1389 error #10 sha256:ff775ddbe9513746f96fa96738f9c2173635b3022a49f0f7928bae5319cef1e8
1389 error #10 CACHED
1389 error
1389 error #17 [internal] load build context
1389 error #17 sha256:54b3adf60544a35396723b91fb32f8a81b8b56dcae852d8a87cd27122e539d4b
1389 error #17 transferring context: 142B done
1389 error #17 DONE 0.0s
1389 error
1389 error #11 [ 8/24] RUN cd /sources/pjsip &&     curl -L -# -o pjsip.tar.bz2 "http://www.pjsip.org/release/2.7.1/pjproject-2.7.1.tar.bz2" &&     tar xjf pjsip.tar.bz2 &&     rm -rf pjsip.tar.bz2 &&     mv pjproject-*/* ./
1389 error #11 sha256:5d169e2b1925c6cd9a0436fa86806bd1f5ae1c2888e8bdac2d62ab857191d8f5
1389 error #11 0.404 #=#=#                                                                         

######################################################################## 100.0%##O#- #                                                                       
##=O#- #                                                                      
#-#O=#  #                                                                     
 #=#=-#   #                                                                   

######################################################################## 100.0%
1389 error #11 1.264 bzip2: (stdin) is not a bzip2 file.
1389 error #11 1.265 tar: Child returned status 2
1389 error #11 1.265 tar: Error is not recoverable: exiting now
1389 error #11 ERROR: executor failed running [/bin/sh -c cd /sources/pjsip &&     curl -L -# -o pjsip.tar.bz2 "$PJSIP_DOWNLOAD_URL" &&     tar xjf pjsip.tar.bz2 &&     rm -rf pjsip.tar.bz2 &&     mv pjproject-*/* ./]: exit code: 2
1389 error ------
1389 error  > [ 8/24] RUN cd /sources/pjsip &&     curl -L -# -o pjsip.tar.bz2 "http://www.pjsip.org/release/2.7.1/pjproject-2.7.1.tar.bz2" &&     tar xjf pjsip.tar.bz2 &&     rm -rf pjsip.tar.bz2 &&     mv pjproject-*/* ./:
1389 error ------
1389 error executor failed running [/bin/sh -c cd /sources/pjsip &&     curl -L -# -o pjsip.tar.bz2 "$PJSIP_DOWNLOAD_URL" &&     tar xjf pjsip.tar.bz2 &&     rm -rf pjsip.tar.bz2 &&     mv pjproject-*/* ./]: exit code: 2
1389 error npm ERR! code 1
1389 error npm ERR! path /Users/dario/.npm/_cacache/tmp/git-clone-8354ee42
1389 error npm ERR! command failed
1389 error npm ERR! command sh -c bash libs.sh
1389 error
1389 error npm ERR! A complete log of this run can be found in:
1389 error npm ERR!     /Users/dario/.npm/_logs/2021-07-05T15_12_01_044Z-debug.log
1390 verbose exit 1

is there a way to access SIP headers when receiving a call?

when I make a call, it is possible to pass extra headers

let options = {
  headers: {
    "P-Assserted-Identity": "Header example",
    "X-UA": "React native"
  }
}

let call = await endpoint.makeCall(account, destination, options);

but how do I access SIP headers passed when receiving a call?

iOS build fails after update to 2.9.0

I already mentioned adn discussed on #3 .
I think it's not fixed yet.

building on simulator was ok with the previous version 2.8.7 but ios build against physical devices

so I updated to 2.9.0 which fixed the issue. but still it fails.

this is the error message I'm getting.
image

Environment

OS X: 10.15.2(Catalina)
Xcode: 11.3
react: '16.9.0',
react-native: '0.61.4',
react-native-sip: '2.9.0'

Android support

Has support been added for sending SIP messages and isTyping for android?

Is it possible to boost microphone gain?

Hello,
Firstly, thanks for a good package.
I am testing my app on two different phones, and it seems to be that audio stream from microphone is a bit deaf and silent.
Is it possible to boost it? Even in native code, it would be ok.
I found an issue about this problem, tried the solution, but the result is not as I expected:
datso/react-native-pjsip#186

Failed to install.

error C:\Users\XXX\Desktop\AwesomeProject\node_modules\react-native-sip: Command failed.
Exit code: 1
Command: bash libs.sh

I'm trying to compile it on windows 10 x64, and dont have any linux machine to compile it now.
The problem it's on package.json who invokes "postinstall": "bash libs.sh". and libs.sh only download from github the latest version of the old repository of Datso (React-native-pjsip).
Can you remove this post install line?

Could not configure 'libc6:i386'.

I executed yarn add react-native-sip in a macOS Catalina 10.15.7. First of all I've got problems with docker that wasn't installed. After fixing it I got this error:

Setting up libgail-common:amd64 (2.24.32-4ubuntu4) ...
Setting up ubuntu-mono (19.04-0ubuntu3) ...
Processing triggers for systemd (245.4-4ubuntu3.2) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Processing triggers for ca-certificates (20190110ubuntu1.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.40.0+dfsg-3) ...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
E: Could not configure 'libc6:i386'. 
E: Could not perform immediate configuration on 'libgcc-s1:i386'. Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)
The command '/bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get -y install     software-properties-common git curl bzip2 gcc g++ binutils make autoconf openssl     libssl-dev ant libopus0 libpcre3 libpcre3-dev build-essential nasm libc6:i386 

I'm missing something? Is there any way to install it on windows?

No audio only mic

Hello guys I have managed to get sip to work but when I accept call I don't get any audio on my device but the microphone is working. I already tried to use useEarpiece and useSpeaker but I cant get it to work.
Using on android x

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.