555 RTC React Native SDK provides an inbuilt component for PSTN or video call feature leveraging the 555 platform. Component's UI theme is configurable by providing the custom style props. It also provide JS-based APIs (in case you need to create your component) for PSTN/video call feature.
- SDK provides component and API for PSTN call
- Provided adavance features like mute/unmute, hold/unhold.
- SDK analytics and stats support
- Way to enable/disable SDK logs
- Updaing SDK APIs(if needed) as per this document)
- Call reconnect feature in case of network failure
- Handling all predefined error codes
- Way to dump logs into a file for debugging purposes
- Advance call features like merge/swap/add call.
- Video call testing and adding custom renderer.
npm install rtc-react-native-sdk
- In XCode, in the project navigator, right-click
Libraries
âžśAdd Files to [your project's name]
- Go to
node_modules
âžśrtc-react-native-SDK
and addRNRtcReactNativeSdk.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRtcReactNativeSdk.a
to your project'sBuild Phases
âžśLink Binary With Libraries
- Add SDK dependent frameworks - WebRTC
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.RNRtcReactNativeSdkPackage;
to the imports at the top of the file - Add
new RNRtcReactNativeSdkPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:
include ':rtc-react-native-sdk'
project(':rtc-react-native-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/rtc-react-native-sdk/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
implementation project(':rtc-react-native-sdk')
The client can make use of either component or JS APIs to implement video and PSTN calls in their application. Before invoking PSTN/Video call API, RTC connection should be connected. Though, SDK API/component will take care of the connection if it is not there. But it is advisable to have RTC connection connected beforehand to minimize call connect time.
Use connect API to establish RTC connection.
import {RtcConnection} from 'rtc-react-native-sdk';
RtcConnection.connect(evmURL, irisToken, routingId);
Property | Type | Values |
---|---|---|
evmURL | string | Server URL for event manager |
irisToken | string | JWT token |
routingId | string | Unique Id for the User |
state callback gives call RTC connection state(connecting/connected/disconnected)
RtcConnection.on("state", (state) => {
console.log("connection status is",state)
}
notification callback gives incoming notification data if client has subscribed for XMPP notification.
RtcConnection.on("notification", (notificationData) => {
console.log("notification",JSON.stringify(notificationData))
}
error callback consists of error code and reason for error during connection.
RtcConnection.on("error", (errorInfo) => {
console.log("Call status is",errorInfo.code)
console.log("Call status is",errorInfo.reason)
}
Use create API to create local stream.
import {RtcStream} from 'rtc-react-native-sdk';
RtcStream.create(callType);
Property | Type | Values |
---|---|---|
callType | string | PSTN/Video |
create API also takes an optional parameters which wil be used to set camera type if calltype is video
import {RtcStream} from 'rtc-react-native-sdk';
RtcStream.create(callType,{
camera : 'BACK/FRONT'})
create API returns a promise. Response will have stream if stream is successful created otherwise error JSON with code and reason for error.
RtcStream.create(callType)
.then(function (stream) {
// stream created
})
.catch(function (error) {
// handle error
console.log(error.code);
console.log(error.reason);
})
To make outgoing calls, pass source phone number, destination phone number, and notification data.
RtcSdk.dial(sourceTN, targetTN, notificationData)
Dial API also takes an optional parameters which allows user to config different options. Also make sure to pass evmURL,irisToken,routingId as optional parameter if RTC connection need to be taken care by dial API
RtcSdk.dial(sourceTN, targetTN, notificationData,{
statsCollectorInterval : '10',
toDomain : '<DOMAIN NAME>'
})
Dial API returns a promise. Response will have callId if call is successful otherwise error JSON with code and reason for error.
RtcSdk.dial(sourceTN, targetTN, notificationData)
.then(function (response) {
// handle success
console.log(response.callId);
})
.catch(function (error) {
// handle error
console.log(error.code);
console.log(error.reason);
})
To accept incoming call, pass the notification payload got in notification.
RtcSdk.accept(notificationData)
Optional configuration parameters can be passed as mentioned in dial API.
Below is the Notification payload need to be populated from incoming notification:
Property | Type | Description |
---|---|---|
callType | string | pstn/video |
roomId | string | Unique room id |
roomToken | string | Room token |
roomTokenExpiryTime | string | Expiry time of room token |
rtcServer | string | RTC server |
remoteTN | string | Caller TN |
traceId | string | trace Id |
RtcSdk.accept(notificationData)
.then(function (response) {
// handle success
console.log(response.callId);
})
.catch(function (error) {
// handle error
console.log(error.code);
console.log(error.reason);
})
Status callback gives call status(initiating/ringing/connected/disconnected)
RtcSdk.on("status", (callId, status) => {
console.log("Call status is",status)
}
Error callback consists of error code and reason for any error occur during a call.
RtcSdk.on("error", (callId, errorInfo) => {
console.log("Call status is",errorInfo.code)
console.log("Call status is",errorInfo.reason)
}
RtcSdk.hangup(callId)
RtcSdk.merge(callId,callIdtobeMerged)
Property | Type | Description |
---|---|---|
callId | string | callId is unique id for this call which was returned from dial/accept API |
callIdtobeMerged | string | callIdtobeMerged is unique id for call to be merged with |
RtcSdk.hold(callId)
Property | Type | Description |
---|---|---|
callId | string | callId is unique id for this call which was returned from dial/accept API |
RtcSdk.unhold(callId)
Property | Type | Description |
---|---|---|
callId | string | callId is unique id for this call which was returned from dial/accept API |
RtcSdk.mute(callId)
Property | Type | Description |
---|---|---|
callId | string | callId is unique id for this call which was returned from dial/accept API |
RtcSdk.unmute(callId)
Property | Type | Description |
---|---|---|
callId | string | callId is unique id for this call which was returned from dial/accept API |
RtcSdk.sendDTMF(callId,number)
Property | Type | Description |
---|---|---|
callId | string | callId is unique id for this call which was returned from dial/accept API |
This component will consist of a keypad dialer and Incall UI screens. All UI button and views will be configurable i.e. you can set your custom styles. This component will be responsible for creating RTC connection (if not there already) and creating a media connection for the voice call when set with required props.
import {RTCDialer} from 'rtc-react-native-sdk';
Name | Type | Description |
---|---|---|
config | Json |
|
mode |
|
To decide if outgoing or incoming call |
notificationPayload | Json | Notification payload for incoming call |
dialerTheme | Json | Custom style for dial pad screen buttons |
inCallViewTheme | Json | Custom style for Incall screen buttons |
Property | Type | Description |
---|---|---|
roomId | string | Unique room id |
roomToken | string | Room token |
roomTokenExpiryTime | string | Expiry time of room token |
rtcServer | string | RTC server |
remoteTN | string | Caller TN |
traceId | string | trace Id |
Name | Parameter | Description |
---|---|---|
onCallStatus(json{callId,status}) | status contains call status :
|
Status of session during call |
onError(json{callId,errorInfo}) | errorInfo contains following info :
|
Error callback invoked if any error during RTC connection or creating session |
componentWillMount() {
this.setState({
mode: 'outgoing',
dialerConfig:
{
"routingId": this.state.routingId,
"irisToken": this.state.token,
"evmUrl": this.state.config.evmServer
}
});
}
render() {
return (
<Dialer
config={this.state.dialerConfig}
mode={this.state.mode}
notificationPayload={this.state.notificationPayload}
onCallStatus={this.onCallStatus.bind(this)}
onError={this.onDialerError.bind(this)}
>
</Dialer>
);
}
In order to make outgoing video call, pass targetEmailId and notification data.
RtcSdk.call(targetEmailId,notificationData)
Call API also takes an optional parameter which allows user to config different options. Pass parameters(evmURL,irisToken,routingId) in optional parameters if RTC connection also needs to be taken care along with making outgoing call. Also you can configure which camera to use while in call.
RtcSdk.call(targetEmailId, notificationData,{
evmURL : 'eventManagerURL',
irisToken : 'JWTToken',
routingId : 'Unique user id'
statsCollectorInterval : '10',
toDomain : '<DOMAIN NAME>',
camera: 'FRONT/BACK'
})
This API return a promise. Response will have callId if call is successful otherwise error json with code and reson for error.
RtcSdk.call(targetEmailId, notificationData)
.then(function (response) {
// handle success
console.log(response.callId);
})
.catch(function (error) {
// handle error
console.log(error.code);
console.log(error.reason);
})
To accept incoming call, pass the notification payload got in notification
RtcSdk.accept(notificationPayload)
Below is the Notification payload need to be populated from incoming notification:
Property | Type | Description |
---|---|---|
callType | string | pstn/video |
roomId | string | Unique room id |
roomToken | string | Room token |
roomTokenExpiryTime | string | Expiry time of room token |
rtcServer | string | RTC server |
traceId | string | trace id |
Optional configuration parameters can be passed as mentioned in dial API.
Accept API return a promise. Response will have callId if call is successful otherwise error JSON with code and reason for error.
RtcSdk.accept(notificationData)
.then(function (response) {
// handle success
console.log(response.callId);
})
.catch(function (error) {
// handle error
console.log(error.code);
console.log(error.reason);
})
status callback gives call status(initiating/connected/disconnected)
RtcSdk.on("status", (callId, status) => {
console.log("Call status is",status)
}
Property | Type | Values |
---|---|---|
callId | string | Unique Id for the call |
status | string | initiating,connected,disconnected |
participant callback gives participant information when any remote participant join.
RtcSdk.on("participant", (callId, participantInfo) => {
console.log("participantInfo Id",participantInfo.id)
console.log("participantInfo name",participantInfo.name)
}
Property | Type | Values |
---|---|---|
callId | string | Unique Id for the call |
participantInfo | JSON | Consist all information about the remote participant |
error callback consists of error code and reason for any error occur during a call.
RtcSdk.on("error", (callId, errorInfo) => {
console.log("Call status is",errorInfo.code)
console.log("Call status is",errorInfo.reason)
}
Property | Type | Values |
---|---|---|
callId | string | Unique Id for the call |
errorInfo | json | code, reason, additionalInfo |
localStream callback will be called when local stream is created
RtcSdk.on("localStream", (callId,stream) => {
}
Property | Type | Values |
---|---|---|
stream | string | local stream |
streamId | string | unique id for stream |
remoteStream callback will be called when remote participant is joined and got remote stream
RtcSdk.on("remoteStream", (callId,stream) => {
}
Property | Type | Values |
---|---|---|
stream | string | remote participant stream |
streamId | string | unique id for stream |
RtcSdk.end(callId)
Property | Type | Description |
---|---|---|
callId | string | callId which is returned from call/accept api |
RtcrRenderer component will be used to render local and remote streams.
Name | Type | Description |
---|---|---|
stream | object | local stream and remote stream which we got from localStream and remoteStream callbacks of RTCSession |
viewConfig |
|
configurations of view which renders the stream |
import {RtcRenderer} from 'rtc-react-native-sdk';
render(){
<RtcRenderer stream={stream} rendererConfig={rendererConfig}/>
}
RtcSession.mute(callId)
Property | Type | Description |
---|---|---|
callId | string | callId which is returned from call/accept API |
RtcSession.unmute(callId)
Property | Type | Description |
---|---|---|
callId | string | callId which is returned from call/accept API |
RtcSession.flip(callId)
Property | Type | Description |
---|---|---|
callId | string | callId which is returned from call/accept API |
This component will consist of video call view screen. All UI button and views will be configurable i.e. you can set your custom styles. This component will be responsible for creating RTC connection (if not there already) and creating a media connection for the voice call when set with required props.
import {RtcVideoCall} from 'rtc-react-native-sdk';
Name | Type | Description |
---|---|---|
config | Json |
|
mode |
|
To decide if outgoing or incoming call |
notificationPayload | Json | Notification payload for incoming call |
videocallViewTheme | Json | Custom style for videocall view screen |
Property | Type | Description |
---|---|---|
roomId | string | Unique room id |
roomToken | string | Room token |
roomTokenExpiryTime | string | Expiry time of room token |
rtcServer | string | RTC server |
traceId | string | trace id |
Name | Parameter | Description |
---|---|---|
onCallStatus(json{callId,status}) | status contains call status :
|
Status of session during call |
onParticipantJoined(json{callId,participantInfo}) | participantInfo contains participant information :
|
remote paritcipant information |
onLocalStream(json{callId,stream}) | contains callId and stream | local stream |
onRemoteStream(json{callId,stream}) | contains callId and stream | remote stream |
onError(json{callId,errorInfo}) | errorInfo contains following info :
|
Error callback invoked if any error during |
componentWillMount() {
this.setState({
mode: 'outgoing',
Config:
{
"routingId": this.state.routingId,
"irisToken": this.state.token,
"targetParticipantEmailId":this.state.emailId,
"evmUrl": this.state.config.evmServer
}
});
}
render() {
return (
<RtcVideoCall
config={this.state.Config}
mode={this.state.mode}
notificationPayload={this.state.notificationPayload}
onCallStatus={this.onCallStatus.bind(this)}
onLocalStream={this.onLocalStream.bind(this)}
onRemoteStream={this.onRemoteStream.bind(this)}
onError={this.onSessionError.bind(this)}
>
</RtcVideoCall>
);
}