React Native webrtc Audio calling package
npm install react-native-calling$ npm install react-native-calling --save
$ npm install native-base uuid react-native-incall-manager react-native-webrtc react-native-websocket --save
1.) In android/app/src/main/AndroidManifest.xml add these permissions
``javascript
`
javascript
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import { InitMedia, signalingConnection, LoginCall, Online, WebSoket, Call } from "react-native-calling";export default class App extends Component {
constructor(props) {
super(props);
this.state = {
loading: true,
localVideo: null,
clientID: null,
username: null,
};
}
async componentDidMount() {
let localVideo = await InitMedia("< webSocketURL >", false);
this.setState({
localVideo: localVideo
});
this.setState({
loading: false
});
signalingConnection.addMsgListener(this.onSignalingMessage);
}
onSignalingMessage = async (msg) => {
switch (msg.type) {
case "id":
// server connecting successful thin server id (this is unique)
this.setState({
clientID: msg.id
});
break;
}
}
render() {
if (this.state.loading) {
return (
loading....
)
}
return (
<>
localStream={this.state.localVideo}
signalingConnection={signalingConnection}
clientID={this.state.clientID}
username={"your App user username (unique)"}
/>
your code only use Call component
>
);
}
}
`
$3
`javascript
import { signalingConnection } from "react-native-calling";signalingConnection.addMsgListener(this.onSignalingMessage);
export default class LiveUserLise extends Component {
constructor(props) {
super(props);
this.state = {
loading: true,
userList: []
};
}
async componentDidMount() {
signalingConnection.addMsgListener(this.onSignalingMessage);
}
onSignalingMessage = async (msg) => {
switch (msg.type) {
case "userlist": // Received an updated user list
this.setState({
userList: msg.userfull
});
break;
}
}
render() {
return (
Your code
)
}
}
`$3
`javascript
import { Online } from "react-native-calling";await Online(); // user this function
`$3
`javascript
import { LoginCall } from "react-native-calling";await LoginCall("youer user name ", "call user username");
``