This is a call sample project using stringee-react-native-v2.
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 startLet 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:
# using npm
npm run android
# OR using Yarn
yarn android# using npm
npm run ios
# OR using Yarn
yarn iosIf 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.
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.
It's the unique identifier of the client on Stringee system.
Whether the client connects to Stringee server:
- true: connected.
- false: not connected.
setListener(stringeeClientListener: StringeeClientListener): void
Set listener for StringeeClient.
Connect to Stringee server using the provided access token.
Disconnect from Stringee server.
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.
Remove the registration deviceToken for push notifications from Stringee server.
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.
It's the unique identifier of the call on Stringee system.
It's the Caller's identifier.
It's the Callee's identifier.
Whether the call is a video call:
- true: is a video call.
- false: is not a video call.
setListener(stringeeCallListener: StringeeCallListener): void
Set listener for StringeeCall.
Make a call.
Initializes an answer. Must be called before answering a call.
Answers a call.
Terminates a call.
Reject a call.
Switches the device's camera. By default, Stringee SDK uses the front camera.
Enables or disables the local stream.
Toggle audio on or off.
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.
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.
It's the unique identifier of the call on Stringee system.
It's the Caller's identifier.
It's the Callee's identifier.
Whether the call is a video call:
- true: is a video call.
- false: is not a video call.
setListener(stringeeCall2Listener: StringeeCall2Listener): void
Set listener for StringeeCall2.
Make a call.
Initializes an answer. Must be called before answering a call.
Answers a call.
Terminates a call.
Reject a call.
Switches the device's camera. By default, Stringee SDK uses the front camera.
Enables or disables the local stream.
Toggle audio on or off.
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.
Represents the event from the StringeeClient.
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.
Represents the event from the StringeeCall.
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.
Represents the event from the StringeeCall2.
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.
Component for rendering the video streams.
It's the unique identifier of the call.
videoTrack: StringeeVideoTrack
It's the video track.
Check whether the stream is local or remote:
- true: Local stream.
- false: Remote stream. By default is true.
scalingType: StringeeVideoScalingType
Scaling type of stream, by default is fill.
To learn more about stringee-react-native-v2, take a look at the following resources:
- stringee-react-native-v2 - stringee-react-native-v2 module in npm.
- Overview - an overview of call API from Stringee.
- Getting Started with StringeeCall - a Getting started document of stringee-react-native-v2 module and how create a call project with StringeeCall.
- Getting Started with StringeeCall2 - a Getting started document of stringee-react-native-v2 module and how create a call project with StringeeCall2.
- API Reference - Specific details about the objects are in stringee-react-native-v2.