Learn how to connect to the chat server and set connection settings.
Visit Key Concepts page to learn the most important QuickBlox concepts.
To connect to the chat server use the code snippet below.
Use QBChatDelegate
to handle different connection states.
In case, you authenticate with QuickBlox via Firebase, Facebook, or Custom Identity Provider, you should connect to the chat server with QuickBlox user session token and QuickBlox user ID.
As a result of successful authentication via Firebase, Facebook, or Custom Identity Provider, you receive a QuickBlox user session token and QuickBlox user ID. Use QuickBlox user session token as a password and QuickBlox user ID as a login to connect to the chat server.
Don’t use the Firebase/Facebook access token as a password to connect to the chat server. You will receive the following runtime error in this case: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/><text xml:lang='en'>Password not verified</text></failure>
.
Argument | Required | Description |
---|---|---|
userID | yes | The ID of a user |
userPassword | yes | Specifies an active QuickBlox user session token set as a password. |
Disconnect from the chat server using the snippet below.
Auto-reconnect is turned off by default. If you want the SDK to automatically reconnect to the chat server when the connection is lost, just enable this option:
Once enabled, the SDK will handle reconnection automatically, no additional code needed.
To provide a seamless chat experience, our SDK manages connections to the chat server at an application-wide level. Thus, to handle offline messages correctly, use the disconnect()
method when an app goes to the background and connect()
method when an app goes to the foreground. As a result, the SDK will disconnect/connect the current user from the chat server when the app goes to the background/foreground mode.
Use the settings below to configure the connection to the chat server.
Parameters | Description |
---|---|
autoReconnectEnabled | iOS SDK reconnects automatically to the chat server when the connection to the server is lost. Default: false. |
reconnectTimerInterval | A reconnect timer can optionally be used to attempt a reconnect periodically. Set in seconds. Default: 5. |
carbonsEnabled | Message carbons allow for real-time message syncing between devices. Default: false. |
keepAliveInterval | Keep-alive option for a socket connection. Keep-alive is the option allowing to detect a stale connection. Set in seconds. Default: 20. |
streamManagementSendMessageTimeout | The timeout value for stream management. Set in seconds. If this parameter is greater than 0, then it is applied, otherwise, it is not applied. Default: 0. |
networkIndicatorManagerEnabled | A boolean value indicating whether the manager is enabled. If true, the manager will change status bar network activity indicator according to network operation notifications it receives. Default: false. |
Learn how to connect to the chat server and set connection settings.
Visit Key Concepts page to learn the most important QuickBlox concepts.
To connect to the chat server use the code snippet below.
Use QBChatDelegate
to handle different connection states.
In case, you authenticate with QuickBlox via Firebase, Facebook, or Custom Identity Provider, you should connect to the chat server with QuickBlox user session token and QuickBlox user ID.
As a result of successful authentication via Firebase, Facebook, or Custom Identity Provider, you receive a QuickBlox user session token and QuickBlox user ID. Use QuickBlox user session token as a password and QuickBlox user ID as a login to connect to the chat server.
Don’t use the Firebase/Facebook access token as a password to connect to the chat server. You will receive the following runtime error in this case: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/><text xml:lang='en'>Password not verified</text></failure>
.
Argument | Required | Description |
---|---|---|
userID | yes | The ID of a user |
userPassword | yes | Specifies an active QuickBlox user session token set as a password. |
Disconnect from the chat server using the snippet below.
Auto-reconnect is turned off by default. If you want the SDK to automatically reconnect to the chat server when the connection is lost, just enable this option:
Once enabled, the SDK will handle reconnection automatically, no additional code needed.
To provide a seamless chat experience, our SDK manages connections to the chat server at an application-wide level. Thus, to handle offline messages correctly, use the disconnect()
method when an app goes to the background and connect()
method when an app goes to the foreground. As a result, the SDK will disconnect/connect the current user from the chat server when the app goes to the background/foreground mode.
Use the settings below to configure the connection to the chat server.
Parameters | Description |
---|---|
autoReconnectEnabled | iOS SDK reconnects automatically to the chat server when the connection to the server is lost. Default: false. |
reconnectTimerInterval | A reconnect timer can optionally be used to attempt a reconnect periodically. Set in seconds. Default: 5. |
carbonsEnabled | Message carbons allow for real-time message syncing between devices. Default: false. |
keepAliveInterval | Keep-alive option for a socket connection. Keep-alive is the option allowing to detect a stale connection. Set in seconds. Default: 20. |
streamManagementSendMessageTimeout | The timeout value for stream management. Set in seconds. If this parameter is greater than 0, then it is applied, otherwise, it is not applied. Default: 0. |
networkIndicatorManagerEnabled | A boolean value indicating whether the manager is enabled. If true, the manager will change status bar network activity indicator according to network operation notifications it receives. Default: false. |