close search

Getting started with Stringee Call2 API using React native

The stringee-react-native package is deprecated. We will continue to support it until the end of 2024. This document is for stringee-react-native-v2, an upgraded version of the old one.

Step 1: Prepare

  1. Before using Stringee Call2 API for the first time, you must have a Stringee account.

    If you do not have a Stringee account, sign up for free here:

  2. Create a Project on Stringee Dashboard

    Stringee create Project

  3. Buy a Number (optional)

  4. For app-to-phone, phone-to-app calling, buy a Number from Dashboard. If you only need app-to-app calling, skip this step.

    Stringee buy Number

  5. Configure answer_url

    For more information about answer_url, read Stringee Call API Overview. You can view answer_url sample code here:

    • Configure Project's answer_url: To make an app-to-app, app-to-phone call, configure your Project's answer_url

    Stringee Project answer_url

    If you do not have answer_url, you can use the following Project's answer_url to accelerate the process:

    Project's answer_url for App-to-App call:

    Project's answer_url for App-to-Phone call:

    (Source code:

    When building an application, you should use your own answer_url.

    • Configure Number's answer_url: To receive a phone-to-app call, configure your Number's answer_url

    Stringee Number answer_url

    If you do not have answer_url, you can use the following Number's answer_url to accelerate the process:

    Number's answer_url for Phone-to-App call (The call is routed to Your App which authenticated by USER_ID):

    Number's answer_url for Phone-to-Phone call (The call is routed to TO_NUMBER):

    (Source code:

Step 2: stringee-react-native-v2 package

  1. In your terminal (Command Prompt in Windows), change into your React Native project's directory

  2. In your terminal (Command Prompt in Windows), run $ npm install stringee-react-native-v2 --save

Step 3: Setup


  1. Permissions

    The Stringee Android SDK requires some permissions from your AndroidManifest

    • Open up android/app/src/main/AndroidManifest.xml
    • Add the following lines:
    // for internet access
    <uses-permission android:name="android.permission.INTERNET" />
    // for audio access
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    // for camera access
    <uses-permission android:name="android.permission.CAMERA" />
    // for bluetooth
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
  2. Proguard

    If your project uses ProGuard, you may have to add the following settings to the ProGuard configuration file to make sure Stringee builds correctly:

    • Create file in your app/ dir and insert inside:
    #Flutter Wrapper
    -dontwarn org.webrtc.**
    -keep class org.webrtc.** { *; }
    -keep class com.stringee.** { *; }
    • Add the following lines to /app/buidl.gradle :
    android {
        buildTypes {
            release {
                useProguard true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
  3. Add volley library

    In your file build.gradle add this line:

    dependencies {
        implementation ''


  1. In you terminal, change into your ios directory, from the command line run following command:

    pod install --repo-update
  2. After run cocoapods command, open project file .xcworkspace

  3. In the "Build Settings" tab -> "Other linker flags" add "$(inherited)" flag

  4. In the "Build Settings" tab -> "Enable bitcode" select "NO"

  5. Right-click the information property list file (Info.plist) and select Open As -> Source Code. Then insert the following XML snippet into the body of your file just before the final element:

    <string>$(PRODUCT_NAME) uses Camera</string>
    <string>$(PRODUCT_NAME) uses Microphone</string>
  6. In the "Build Settings" tab -> "Allow Non-modular includes in Framework Modules" select "YES"

Step 4: Connect to Stringee Server

In order to connect to Stringee Server, 3-parties authentication is required as described here: Client authentication

For testing purpose, go to Dashboard -> Tools -> Generate Access token and generates an access_token. In production, the access_token should be generated by your server, sample code generates access token here:

  1. Initialize StringeeClient:

    import {StringeeClient} from 'stringee-react-native-v2';
    const stringeeClient: StringeeClient = new StringeeClient();
  2. Register the client's events

    // Listen for the StringeeClient event
    const stringeeClientListener: StringeeClientListener = new StringeeClientListener();
    // Invoked when the StringeeClient is connected
    clientListener.onConnect = (stringeeClient, userId) => {
      console.log('onConnect: ', userId);
    // Invoked when the StringeeClient is disconnected
    clientListener.onDisConnect = (stringeeClient) => {
    // Invoked when StringeeClient connect false
    clientListener.onFailWithError = (stringeeClient, code, message) => {
      console.log('onFailWithError: ', message);
    // Invoked when your token is expired
    clientListener.onRequestAccessToken = (stringeeClient) => {
    // Invoked when receive an incoming of StringeeCall
    clientListener.onIncomingCall = (stringeeClient, stringeeCall) => {
      console.log('onIncomingCall: ', JSON.stringify(stringeeCall));
    // Invoked when receive an incoming of StringeeCall2
    clientListener.onIncomingCall2 = (stringeeClient, stringeeCall2) => {
      console.log('onIncomingCall2: ', JSON.stringify(stringeeCall2));
  3. Connect

    token: string = 'PUT YOUR TOKEN HERE'

Step 5: Make a call

After the client connects to Stringee server, follows these steps to make a call:

  1. Initialize StringeeCall2

    import {StringeeCall2} from 'stringee-react-native-v2';
    stringeeCall2: StringeeCall2 = new StringeeCall2({
      stringeeClient: stringeeClient, /// stringeeClient using to connect
      from: 'caller_userId', /// caller identifier
      to: 'callee_userId', /// callee identifier
  2. Register the call's events

    // Listen for the StringeeCall2 event
    const stringeeCall2Listener: StringeeCall2Listener = new StringeeCall2Listener();
    // Invoked when the call's signaling state changes
    stringeeCall2Listener.onChangeSignalingState = (stringeeCall2, signalingState, reason, sipCode, sipReason) => {
      console.log('onChangeSignalingState', signalingState);
    // Invoked when the call's media state changes
    stringeeCall2Listener.onChangeMediaState = (stringeeCall2, mediaState, description) => {
      console.log('onChangeMediaState', mediaState);
    // Invoked when receive call info
    stringeeCall2Listener.onReceiveCallInfo = (stringeeCall2, callInfo) => {
      console.log('onReceiveCallInfo', callInfo);
    // Invoked when an incoming call is handle on another device
    stringeeCall2Listener.onHandleOnAnotherDevice = (stringeeCall2, signalingState, description) => {
      console.log('onHandleOnAnotherDevice', signalingState);
    // Invoked when the local track is initialized and available to be rendered to a view.
    stringeeCall2Listener.onReceiveLocalTrack = (stringeeCall2, stringeeVideoTrack) => {
    // Invoked when the remote track is initialized and available to be rendered to a view.
    stringeeCall2Listener.onReceiveRemoteTrack = (stringeeCall2, stringeeVideoTrack) => {
    // Invoked when the current audio device changes in android
    stringeeCall2Listener.onAudioDeviceChange = (stringeeCall2, selectedAudioDevice, availableAudioDevices) => {
      console.log('onAudioDeviceChange', selectedAudioDevice);
  3. Make a call

      .then(() => {
         console.log('makeCall success');

Step 6: Answer a call

After the client receives an incoming call from onIncomingCall2(). Following these steps:

  1. Initialize the answer

      .then(() => {
         console.log('initAnswer success');
  2. Answer

      .then(() => {
         console.log('answer success');

Step 7: Make a video call

  1. A StringeeCall2 is a voice call by default. If you want to make a video call, you must set property isVideoCall of StringeeCall2 to true.
    stringeeCall2.isVideoCall = true;
  2. Receive and display the local video and the remote video

    Using our StringeeVideoView to display the video

    // Invoked when the local track is initialized and available to be rendered to a view.
    stringeeCall2Listener.onReceiveLocalTrack = (stringeeCall2, stringeeVideoTrack) => {
         hasReceivedLocalTrack: true,
         localTrack: stringeeVideoTrack,
    // Invoked when the remote track is initialized and available to be rendered to a view.
    stringeeCall2Listener.onReceiveRemoteTrack = (stringeeCall2, stringeeVideoTrack) => {
         hasReceivedRemoteTrack: true,
         remoteTrack: stringeeVideoTrack,
    render () {
      return (
        {stringeeCall2.isVideoCall &&
          this.localTrack &&
          this.state.hasReceivedLocalTrack && (
        {stringeeCall2.isVideoCall &&
          this.remoteTrack &&
          this.state.hasReceivedRemoteTrack && (
              style={{flex: 1}}

Step 8: Hang up

Hang up a call:

      .then(() => {
         console.log('hangup success');

Step 9: Reject

Reject a call:

      .then(() => {
         console.log('reject success');

Step 10: Mute

Mute the local sound:

   mute: boolean = true; // true: mute, false: unmute
      .then(() => {
         console.log('mute success');

Step 11: Switch speaker or bluetooth device

Switch to speakerphone or earpiece:

   isSpeaker: boolean = true; // true: speakerphone, false: earpiece
      .then(() => {
         console.log('setSpeakerphoneOn success');

Step 12: Switch camera

Switch the local camera:

      .then(() => {
         console.log('switchCamera success');

Step 13: Turn on/off video

Turn on/off video:

   enableVideo: boolean = true; // true: turn on, false: turn off
      .then(() => {
         console.log('enableVideo success');


You can view a full version of this sample app on GitHub: