Suggestions

close search

StringeeClient

Represents a Stringee client, manages the client's connection. This component provides methods to connect to/disconnect from Stringee server, receives the connection's events, the incoming call event.

Props

eventHandlers: Object

Event handlers passed into the native StringeeClient instance. Example:


            clientEventHandlers = {
              onConnect: this._clientDidConnect,
              onDisConnect: this._clientDidDisConnect,
              onFailWithError: this._clientDidFailWithError,
              onRequestAccessToken: this._clientRequestAccessToken,
              onIncomingCall: this._callIncomingCall
            };
          

Events

onConnect : Function(userId: string, projectId: string, isReconnecting: boolean)

Invoked when the client connects to Stringee server:
- userId: It's the unique identification of the client on Stringee system.
- projectId: Id of your project.
- isReconnecting = YES: The client is reconnecting, isReconnecting = NO: The client connects first time.

onDisConnect : Function(userId: string, projectId: string, isReconnecting: boolean)

Invoked when the client connects to Stringee server:
- userId: It's the unique identification of the client on Stringee system.
- projectId: Id of your project.
- isReconnecting = YES: The client is reconnecting, isReconnecting = NO: The client connects first time.

onFailWithError : Function(userId: string, code: int, message: string)

Invoked when the client fails to connect to Stringee server:
- userId: It's the unique identification 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 : Function()

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

onIncomingCall : Function(userId: string, callId: string, from: string, to: string, fromAlias: string, toAlias: string, callType: int, isVideoCall: boolean, customDataFromYourServer: string)

Invoked when the client receives an incoming call:
- userId: It's the unique identification of the client on Stringee system.
- callId: The call's id generated by Stringee server.
- from: The caller's phone number or id.
- to: The callee's phone number or id.
- fromAlias: The alias of the caller.
- toAlias: The alias of the callee.
- callType: The type of the call:
    + callType = 0, App-to-app-outgoing-call
    + callType = 1, App-to-app-incoming-call
    + callType = 2, App-to-phone
    + callType = 3, Phone-to-app
- isVideoCall: Whether the call is a video call:
    + isVideoCall = true, a video call
    + isVideoCall = false, a voice call
- customDataFromYourServer: The custom data from your server when a client makes a call or receives an incoming call.

Functions

connect(token: string)

Connects to Stringee server with an access token:
- token: your access token.

disconnect()

Disconnects from Stringee server.

registerPush(deviceToken: string, isProduction: boolean, isVoip: boolean, callback:(status, code, message))

Register device token to receive push notification. When you have an incoming call, you receive a notification from Stringee server:
- deviceToken: the token received from Apple's server when you register push notification to Apple (iOS).
- isProduction = true : For production environment, isProduction = false: For development environment (iOS).
- isVoip = true: To receive voip push notification, isVoip = false: To receive remote push notification (iOS).
callback returns the result of the registration:
- status = true, code = 0, message = "Register successfully."
- status = false, code = 1, message = "The Bundle Identifier has not been configured.".
- status = false, code = -1, message = "StringeeClient is not initialized or connected".
- status = false, code = -2, message = "Data is empty.".
- status = false, code = -3, message = "Generic error.".

unregisterPush(deviceToken: string, callback: (status, code, message))

Remove your device token from Stringee server. Your device will not receive push notification when you have an incoming call: deviceToken: The device token which registered.
callback returns the result of unregistering:
- status = true, code = 0, message = "Unregister successfully."
- status = false, code = 1, message = "The Bundle Identifier has not been configured.".
- status = false, code = -1, message = "StringeeClient is not initialized or connected".
- status = false, code = -2, message = "Generic error".