There are three user statuses:
Note:The PushOnline status exists only on mobile clients (Android, iOS, and iPad) but not on PC, Mac, Linux, Mini Program, and web clients.
The Online status means that 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 a user opens an app, the status is Online.
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 links, platforms, and versions. When the app is running, the IM SDK regularly sends heartbeats to confirm the online status of the user.
Note:Heartbeat: The IM SDK sends a heartbeat packet to the server every two minutes to confirm the online status.
When a client is in the PushOnline status, the TCP persistent connection between the client and the IM server is disconnected. In this case, messages pushed offline can be received.
In the following scenarios, the user’s status is PushOnline:
Note:The PushOnline status exists only on mobile clients (Android, iOS, and iPad) but not on PC, Mac, Linux, Mini Program, and web clients.
Offline refers to the status before a user enters the username and password for login. In this case, the user cannot receive online and offline message pushes.
In the following scenarios, the status is Offline:
The app backend can query the online status of multiple users via the v4/openim/querystate RESTful API.
Currently, the IM SDK cannot get the online status of users.
IM can notify the app backend of user login and logout events. For more information, see Status Change Callback.
In most cases, the changes of user status can be detected in real time. For example:
In the following special case, it will take 400 seconds before the heartbeat times out. After that, the IM CVM instance can detect the status change:
When the network is completely unavailable and the client cannot even send TCP FIN or RST packets, it will take 400 seconds before the heartbeat times out. After that, the IM CVM instance can detect that the user’s status changes to PushOnline. This commonly occurs when the user disconnects the client from the network (for example, by enabling the airplane mode on the mobile phone) or the user enters a tunnel with no network signal.
When a user logs in on the web client, the IM CVM can detect in real time that the user’s status changes to Online.
The timeliness of status change in various exit/disconnection scenarios is as follows:
destroy
API can be perceived in real time, and the status will change to Offline.When a user logs in on the Mini Program client, the IM CVM can detect in real time that the user’s status changes to Online.
The timeliness of status change in various exit/disconnection scenarios is as follows:
destroy
API can be detected in real time, and the status will change to Offline.By default, the IM SDK does not allow multi-device login (for example, simultaneous login on a PC and an Android device). Instead, it forces the previous online device to go offline and allows only the last logged-in device to stay online. For more information on the force offline logic, see:
IM allows you to modify the multi-client login policy in the console. Currently, the following multi-client login policies are supported:
By default, a user can be online on only one device for each platform (for example, one Android client will force another Android client to go offline). For users on Flagship Edition, you can configure the maximum number of instances that they can log in to on the Android, iPhone, iPad, Windows, or Mac platform. In addition, you can configure the maximum number of instances that all users can log in to on the web platform.
Was this page helpful?