- Android
- iOS
- JavaScript
- Flutter
- ReactNative
- HarmonyOS
Connect
Connecting to the IM server is asynchronous. Connection state is returned through the connection listener; configure the listener before initialization.
Render conversation and message UI in the onDbOpen() callback.
Send messages in the onStatusChange() callback when the connection state becomes JIMConst.ConnectionStatus.CONNECTED.
Call connect only once. The SDK then opens the database, establishes the network connection, and handles all subsequent reconnection logic.
Developer intervention is required only for conditions the SDK cannot handle, such as an invalid Token or a banned application.
Handle errors by error code when JIMConst.ConnectionStatus.FAILURE is observed.
JIM.getInstance().getConnectionManager().connect("token");
Disconnect
When disconnecting, choose whether to continue receiving push notifications.
// true continues receiving push notifications after disconnecting
// false stops receiving push notifications after disconnecting
JIM.getInstance().getConnectionManager().disconnect(false);
Connect
After connecting, register a connection listener for subsequent business handling.
Render conversation and message UI in the dbDidOpen callback.
Send messages in the connectionStatusDidChange:errorCode callback when the connection state becomes JConnectionStatusConnected.
Developers need to call connectWithToken only once. The SDK then opens the database, establishes the network connection, and handles all subsequent reconnection logic.
Developer intervention is needed only for situations the SDK cannot handle, such as an invalid Token or a blocked app.
Handle errors by error code when JConnectionStatusFailure is observed.
[JIM.shared.connectionManager connectWithToken:@"token"];
Disconnect
When disconnecting, you can choose whether to continue receiving message push notifications.
// YES continues receiving push notifications after disconnecting
// NO stops receiving push notifications after disconnecting
[JIM.shared.connectionManager disconnect:NO];
Parameters
| Parameter | Type | Required | Description | Minimum version |
|---|---|---|---|---|
| user | Object | Yes | 1.0.0 | |
| user.token | String | Yes | User authentication token generated by the developer server according to the IM server rules. | 1.0.0 |
Callback
| Property | Type | Description | Version |
|---|---|---|---|
| error | Object | Connection result. | 1.0.0 |
| error.code | Number | Connection result status code. See connection status codes for details. | 1.0.0 |
| error.msg | String | Connection result description. See connection status codes for details. | 1.0.0 |
Example
let { ErrorType } = JIM;
let jim = JIM.init({ appkey: 'Your AppKey' });
let user = {
token: "CgZhcHBrZXkaIDAr072n8uOcw5YBeKCcQ+QCw4m6YWhgt99U787/dEJS"
};
jim.connect(user).then((user) => {
console.log('connect successfully', user);
}, (error) => {
console.log('connect failed', error);
});
Connect
After connecting, register a connection listener for subsequent application handling.
Developers need to call connect only once. The SDK then opens the database, establishes the network connection, and handles all subsequent reconnection logic.
Developer intervention is needed only for situations the SDK cannot handle, such as an invalid Token or a blocked App.
Handle errors by error code when SDKConnectionStatus.FAILURE is observed.
await _juggleImPlugin.connect('token');
Disconnect
When disconnecting, you can choose whether to continue receiving message push notifications.
// true continues receiving push notifications after disconnecting
// false stops receiving push notifications after disconnecting
await JuggleIm.instance.disconnect(false);
Connect
After connecting, register a connection listener for subsequent application handling.
Developers need to call connect only once. The SDK then opens the database, establishes the network connection, and handles all subsequent reconnection logic.
Developer intervention is needed only for situations the SDK cannot handle, such as an invalid Token or a blocked app.
Handle errors by error code when ConnectionStatus.FAILURE is observed.
Parameters
| Parameter | Type | Required | Description | Minimum Version |
|---|---|---|---|---|
| token | String | Yes | User authentication token generated on the developer's server according to the IM Server rules. | 1.0.0 |
Code Example
import JuggleIM from 'juggleim-rnsdk';
JuggleIM.connect('your-token');
Disconnect
When disconnecting, you can choose whether to continue receiving message push notifications.
Parameters
| Parameter | Type | Required | Description | Minimum Version |
|---|---|---|---|---|
| pushable | Boolean | Yes | true continues receiving push notifications after disconnecting; false stops receiving them after disconnecting. | 1.0.0 |
Code Example
// true continues receiving push notifications after disconnecting
// false stops receiving push notifications after disconnecting
JuggleIM.disconnect(false);
Code Example
JuggleIm.instance.getConnectionManager().connect("{token}")