Skip to main content

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);