When a client is online, a smooth TCP connection is maintained between the client and the IM server. In this condition, the client can send messages to the IM server and receive messages from it.
When an app starts, a TCP persistent connection is established between the client and the IM server. The IM server saves the online information of clients, such as network linkages and platform versions. After the persistent connection is established, the IM SDK sends regular heartbeats to confirm the online status of the user during app operations. When the TCP connection between an iOS or Android client and IM is disconnected, the client continues to receive offline push messages even though it is not online.
Heartbeat: Every two minutes, the IM SDK sends a heartbeat packet to the server to confirm the user’s online status.
Connection refers to the action by which a TCP persistent connection is established between an app client and the IM server.
Disconnection occurs in the following scenarios:
To differentiate among online, connection, and disconnection, you need to check whether a network connection is present between the client and the IM backend. iOS and Android users can still receive offline push messages even when they are not online.
The app backend can query the online status of multiple users.
Currently, the IM SDK cannot obtain users’ online statuses.
IM can notify the app backend of user connection and disconnection events.
By default, the IM SDK does not allow multi-device login (for example, simultaneous login on a PC and Android devices). Instead, it forces the previous online device to go offline and allows only the last logged-in device to stay online.
You can modify the multi-device login policy in IM Console to allow users to stay online simultaneously on a PC and mobile phone, or on a PC, iOS device, and Android device. When multi-device login is enabled, users can stay online simultaneously on different devices with different platforms, but not on devices with the same platform. For example, simultaneous login on two iOS devices will trigger force offline.