public class StringeeClient
Represents a Stringee client, manages connection, call, chat, and room events.
| Constructors | |
|---|---|
Constructor |
StringeeClient({List<StringeeServerAddress>? serverAddresses, String? baseAPIUrl})Creates a StringeeClient instance. |
| Properties | |
|---|---|
String? |
userIdCurrent connected user id. |
String? |
projectIdCurrent project id. |
bool |
hasConnectedWhether the client is connected. |
bool |
isReconnectingWhether the current connection event is a reconnect. |
StreamController<dynamic> |
eventStreamControllerStream of client, call, chat, and room events for this client instance. |
String |
uuidUnique native client instance id. |
| Events | |
|---|---|
StringeeClientEvents |
didConnectInvoked when the client connects successfully. |
StringeeClientEvents |
didDisconnectInvoked when the client disconnects. |
StringeeClientEvents |
didFailWithErrorInvoked when connection fails; body contains code and message. |
StringeeClientEvents |
requestAccessTokenInvoked when a new access token is required. |
StringeeClientEvents |
tokenWillExpireInvoked about 60 seconds before the access token expires. |
StringeeClientEvents |
didReceiveCustomMessageInvoked when the client receives a custom message. |
StringeeClientEvents |
incomingCallInvoked for an incoming StringeeCall. |
StringeeClientEvents |
incomingCall2Invoked for an incoming StringeeCall2. |
StringeeClientEvents |
didReceiveChatRequestInvoked when a live chat request is received. |
StringeeClientEvents |
didReceiveTransferChatRequestInvoked when a transferred live chat request is received. |
StringeeClientEvents |
timeoutAnswerChatInvoked when answering a chat request times out. |
StringeeClientEvents |
timeoutInQueueInvoked when the visitor times out in queue. |
StringeeClientEvents |
conversationEndedInvoked when a conversation is ended. |
StringeeClientEvents |
userBeginTypingInvoked when a user begins typing. |
StringeeClientEvents |
userEndTypingInvoked when a user ends typing. |
| Public methods | |
|---|---|
Future<Map<dynamic, dynamic>> |
connect(String token)Connects this client with an access token. |
Future<Map<dynamic, dynamic>> |
updateToken(String token)Renews the access token on the open connection without reconnecting. |
Future<Map<dynamic, dynamic>> |
disconnect()Disconnects this client from Stringee. |
Future<Map<dynamic, dynamic>> |
registerPush(String deviceToken, {bool? isProduction, bool? isVoip})Registers a push notification token. |
Future<Map<dynamic, dynamic>> |
registerPushAndDeleteOthers(String deviceToken, List<String> packageNames, {bool? isProduction, bool? isVoip})Registers a push token and removes tokens from the provided package names. |
Future<Map<dynamic, dynamic>> |
unregisterPush(String deviceToken)Unregisters a push notification token. |
Future<Map<dynamic, dynamic>> |
sendCustomMessage(String userId, Map<dynamic, dynamic> customData)Sends custom data to a Stringee user. |
Future<Result> |
existCall(String callId)Checks whether a call exists on the Stringee server. |
StringeeClient({List<StringeeServerAddress>? serverAddresses, String? baseAPIUrl}) |
|---|
| Creates a StringeeClient instance. |
userId |
|---|
| Current connected user id. |
projectId |
|---|
| Current project id. |
hasConnected |
|---|
| Whether the client is connected. |
isReconnecting |
|---|
| Whether the current connection event is a reconnect. |
eventStreamController |
|---|
| Stream of client, call, chat, and room events for this client instance. |
uuid |
|---|
| Unique native client instance id. |
didConnect |
|---|
| Invoked when the client connects successfully. |
didDisconnect |
|---|
| Invoked when the client disconnects. |
didFailWithError |
|---|
| Invoked when connection fails; body contains code and message. |
requestAccessToken |
|---|
Invoked when a new access token is required: the token was rejected, or it expired without being renewed and the server closed the connection. The SDK does not reconnect by itself; call connect(newToken) on the same client with a new token from your server to resume the session. |
tokenWillExpire |
|---|
Invoked about 60 seconds before the access token expires. Fetch a new token for the same user from your server and pass it to updateToken to keep the connection open. If the token is not renewed, the server closes the connection when it expires and requestAccessToken is invoked. Available from plugin 1.3.4 (Android SDK 2.1.18, iOS SDK 2.2.0). |
body: Map with exp (int, token expiry time in epoch seconds) and expireInSeconds (int, seconds left before the token expires). |
didReceiveCustomMessage |
|---|
| Invoked when the client receives a custom message. |
incomingCall |
|---|
| Invoked for an incoming StringeeCall. |
incomingCall2 |
|---|
| Invoked for an incoming StringeeCall2. |
didReceiveChatRequest |
|---|
| Invoked when a live chat request is received. |
didReceiveTransferChatRequest |
|---|
| Invoked when a transferred live chat request is received. |
timeoutAnswerChat |
|---|
| Invoked when answering a chat request times out. |
timeoutInQueue |
|---|
| Invoked when the visitor times out in queue. |
conversationEnded |
|---|
| Invoked when a conversation is ended. |
userBeginTyping |
|---|
| Invoked when a user begins typing. |
userEndTyping |
|---|
| Invoked when a user ends typing. |
connect(String token) |
|---|
| Connects this client with an access token. |
updateToken(String token) | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Renews the access token on the open connection without reconnecting. Call it after tokenWillExpire. On success the SDK keeps the new token, also for automatic reconnects. On failure the connection stays open until the current token expires. Available from plugin 1.3.4 (Android SDK 2.1.18, iOS SDK 2.2.0). | ||||||||||||||
token: new access token for the same user and project. | ||||||||||||||
Returns Map with status (bool), code (int) and message (String). The codes are the same on Android and iOS: | ||||||||||||||
|
disconnect() |
|---|
| Disconnects this client from Stringee. |
registerPush(String deviceToken, {bool? isProduction, bool? isVoip}) |
|---|
| Registers a push notification token. |
registerPushAndDeleteOthers(String deviceToken, List<String> packageNames, {bool? isProduction, bool? isVoip}) |
|---|
| Registers a push token and removes tokens from the provided package names. |
unregisterPush(String deviceToken) |
|---|
| Unregisters a push notification token. |
sendCustomMessage(String userId, Map<dynamic, dynamic> customData) |
|---|
| Sends custom data to a Stringee user. |
existCall(String callId) |
|---|
| Checks whether a call exists on the Stringee server. |