Skip to content

Latest commit

 

History

History

README.md

This is a call sample project using stringee-react-native-v2.

Getting Started

Step 1: Start the Metro Server

First, you will need to start Metro, the JavaScript bundler that ships with React Native.

To start Metro, run the following command from the root of your React Native project:

# using npm
npm start

# OR using Yarn
yarn start

Step 2: Start your Application

Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your Android or iOS app:

For Android

# using npm
npm run android

# OR using Yarn
yarn android

For iOS

# using npm
npm run ios

# OR using Yarn
yarn ios

If everything is set up correctly, you should see your new app running in your Android Emulator or iOS Simulator shortly provided you have set up your emulator/simulator correctly.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

Learn more about stringee-react-native-v2 objects

StringeeClient

Represents a Stringee client, manages the client's connection. This class provides methods to connect to/disconnect from Stringee server, manage Conversation, receives the connection's events, the incoming call event, Conversation and Message change event.

Properties

userId: string

It's the unique identifier of the client on Stringee system.

isConnected: boolean

Whether the client connects to Stringee server:

  • true: connected.
  • false: not connected.

Methods

setListener(stringeeClientListener: StringeeClientListener): void

Set listener for StringeeClient.

connect(token: string): void

Connect to Stringee server using the provided access token.

disconnect(): void

Disconnect from Stringee server.

registerPush(deviceToken: string, isProduction: boolean, isVoip: boolean): Promise<void>

Register the registration deviceToken for push notifications to Stringee server. For iOS need 2 values for register push:

  • isProduction:
    • true: For production environment.
    • false: For development environment.
  • isVoip:
    • true: To receive voip push notification.
    • false: To receive remote push notification.
unregisterPush(deviceToken: string): Promise<void>

Remove the registration deviceToken for push notifications from Stringee server.

StringeeCall

Represents a voice, video call. Used to capture an audio-video stream from the device's microphone and camera for use to make or answer a call.

Properties

callId: string

It's the unique identifier of the call on Stringee system.

from: string

It's the Caller's identifier.

to: string

It's the Callee's identifier.

isVideoCall: boolean

Whether the call is a video call:

  • true: is a video call.
  • false: is not a video call.

Methods

setListener(stringeeCallListener: StringeeCallListener): void

Set listener for StringeeCall.

makeCall(): Promise<void>

Make a call.

initAnswer(): Promise<void>

Initializes an answer. Must be called before answering a call.

answer(): Promise<void>

Answers a call.

hangup(): Promise<void>

Terminates a call.

reject(): Promise<void>

Reject a call.

switchCamera(): Promise<void>

Switches the device's camera. By default, Stringee SDK uses the front camera.

enableVideo(enabled: boolean): Promise<void>

Enables or disables the local stream.

mute(mute: boolean): Promise<void>

Toggle audio on or off.

setSpeakerphoneOn(on: boolean): Promise<void>

Set the audio output mode. If you want to use the device loudspeaker for playing audio, call the setSpeakerphoneOn(true) method. Otherwise, call the setSpeakerphoneOn(false) method to use headset speaker for playing audio.

StringeeCall2

Represents a voice, video call. Used to capture an audio-video stream from the device's microphone and camera for use to make or answer a call.

Properties

callId: string

It's the unique identifier of the call on Stringee system.

from: string

It's the Caller's identifier.

to: string

It's the Callee's identifier.

isVideoCall: boolean

Whether the call is a video call:

  • true: is a video call.
  • false: is not a video call.

Methods

setListener(stringeeCall2Listener: StringeeCall2Listener): void

Set listener for StringeeCall2.

makeCall(): Promise<void>

Make a call.

initAnswer(): Promise<void>

Initializes an answer. Must be called before answering a call.

answer(): Promise<void>

Answers a call.

hangup(): Promise<void>

Terminates a call.

reject(): Promise<void>

Reject a call.

switchCamera(): Promise<void>

Switches the device's camera. By default, Stringee SDK uses the front camera.

enableVideo(enabled: boolean): Promise<void>

Enables or disables the local stream.

mute(mute: boolean): Promise<void>

Toggle audio on or off.

setSpeakerphoneOn(on: boolean): Promise<void>

Set the audio output mode. If you want to use the device loudspeaker for playing audio, call the setSpeakerphoneOn(true) method. Otherwise, call the setSpeakerphoneOn(false) method to use headset speaker for playing audio.

StringeeClientListener

Represents the event from the StringeeClient.

Methods

onConnect: (stringeeClient: StringeeClient, userId: string) => void

Invoked when the StringeeClient is connected.

  • userId: It's the unique identifier of the client on Stringee system.
onDisConnect: (stringeeClient: StringeeClient) => void

Invoked when the StringeeClient is disconnected.

onFailWithError: (stringeeClient: StringeeClient, code: number, message: string) => void

Invoked when StringeeClient connect false.

  • userId: It's the unique identifier of the client on Stringee system.
  • code = 1, message = "Access token is empty"
  • code = 2, message = "Access token can not be decoded"
  • code = 3, message = "Access token invalid format"
  • code = 4, message = "Access token does not use HS256"
  • code = 5, message = "API key sid or account sid not found"
  • code = 6, message = "Access token expired or invalid"
  • code = 7, message = "Access token invalid payload"
  • code = 8, message = "Project not found"
onRequestAccessToken: (stringeeClient: StringeeClient) => void

Invoked when your token is expired. You must get a new token and reconnect.

onIncomingCall: (stringeeClient: StringeeClient, stringeeCall: StringeeCall) => void

Invoked when receive an incoming of StringeeCall.

onIncomingCall2: (stringeeClient: StringeeClient, stringeeCall2: StringeeCall2 ) => void

Invoked when receive an incoming of StringeeCall2.

StringeeCallListener

Represents the event from the StringeeCall.

Methods

onChangeSignalingState: (stringeeCall: StringeeCall, signalingState: SignalingState, reason: string, sipCode: number, sipReason: string) => void

Invoked when the call's signaling state changes.

  • signalingState: The signaling state of the call:
    • calling.
    • ringing.
    • answered.
    • ended.
    • busy.
  • reason: The description of the state.
  • sipCode: The sip code returned when the call is an app-to-phone call.
  • sipReason: The description of sip code.
onChangeMediaState: (stringeeCall: StringeeCall, mediaState: MediaState, description: string) => void

Invoked when the call's media state changes.

  • mediaState: The media state of the call:
    • connected: Used to specify the call media is connected.
    • disconnected: Used to specify the call media is disconnected.
  • description: The description of the state.
onHandleOnAnotherDevice: (stringeeCall: StringeeCall, signalingState: SignalingState, reason: string) => void

Invoked when an incoming call is handle on another device.

  • signalingState: The signaling state of the call:
    • calling.
    • ringing.
    • answered.
    • ended.
    • busy.
  • reason: The description of the state.
onReceiveLocalStream: (stringeeCall: StringeeCall) => void

Invoked when local stream in video call is ready to play.

onReceiveRemoteStream: (stringeeCall: StringeeCall) => void

Invoked when remote stream in video call is ready to play.

onAudioDeviceChange: (stringeeCall: StringeeCall, selectedAudioDevice: AudioDevice, availableAudioDevices: Array<AudioDevice>) => void

Invoked when the current audio device changes in android.

  • availableAudioDevices: List available audio devices on your android device.
  • selectedAudioDevice: Audio device was selected:
    • speakerPhone : Speaker phone.
    • wiredHeadset : Wired headset.
    • earpiece : Earpiece.
    • bluetooth : Bluetooth headphone.
    • none : None device selected.

StringeeCall2Listener

Represents the event from the StringeeCall2.

Methods

onChangeSignalingState: (stringeeCall2: StringeeCall2, signalingState: SignalingState, reason: string, sipCode: number, sipReason: string) => void

Invoked when the call's signaling state changes.

  • signalingState: The signaling state of the call:
    • calling.
    • ringing.
    • answered.
    • ended.
    • busy.
  • reason: The description of the state.
  • sipCode: The sip code returned when the call is an app-to-phone call.
  • sipReason: The description of sip code.
onChangeMediaState: (stringeeCall2: StringeeCall2, mediaState: MediaState, description: string) => void

Invoked when the call's media state changes.

  • mediaState: The media state of the call:
    • connected: Used to specify the call media is connected.
    • disconnected: Used to specify the call media is disconnected.
  • description: The description of the state.
onHandleOnAnotherDevice: (stringeeCall2: StringeeCall2, signalingState: SignalingState, reason: string) => void

Invoked when an incoming call is handle on another device.

  • signalingState: The signaling state of the call:
    • calling.
    • ringing.
    • answered.
    • ended.
    • busy.
  • reason: The description of the state.
onReceiveLocalTrack: (stringeeCall2: StringeeCall2, stringeeVideoTrack: StringeeVideoTrack) => void

Invoked when the local track is initialized and available to be rendered to a view..

onReceiveRemoteTrack: (stringeeCall2: StringeeCall2, stringeeVideoTrack: StringeeVideoTrack) => void

Invoked when the remote track is initialized and available to be rendered to a view.

onAudioDeviceChange: (stringeeCall2: StringeeCall2, selectedAudioDevice: AudioDevice, availableAudioDevices: Array<AudioDevice>) => void

Invoked when the current audio device changes in android.

  • availableAudioDevices: List available audio devices on your android device.
  • selectedAudioDevice: Audio device was selected:
    • speakerPhone : Speaker phone.
    • wiredHeadset : Wired headset.
    • earpiece : Earpiece.
    • bluetooth : Bluetooth headphone.
    • none : None device selected.

StringeeVideoView

Component for rendering the video streams.

Properties

uuid: string

It's the unique identifier of the call.

videoTrack: StringeeVideoTrack

It's the video track.

local: boolean

Check whether the stream is local or remote:

  • true: Local stream.
  • false: Remote stream. By default is true.

Scaling type of stream, by default is fill.

Learn More

To learn more about stringee-react-native-v2, take a look at the following resources: