Skip to main content

Disconnect

When the app needs to switch user logins or log out, it is necessary to disconnect from the RC IM connection. The SDK supports setting whether to allow push notifications to users after disconnecting the IM connection.

tip

The SDK automatically reconnects when switching between foreground and background or when network exceptions occur, ensuring connection reliability. Unless the app logic requires logout, there is no need to manually disconnect.

Disconnect (Allow Push)

Actively disconnect from the RC server-side IM connection and allow the RC server to perform remote push notifications after disconnecting. The following two methods have the same effect.

[[RCIMClient sharedRCIMClient] disconnect];

Or:

[[RCIMClient sharedRCIMClient] disconnect:YES];
ParameterTypeDescription
isReceivePushBOOLWhether to allow the RC server to perform remote push notifications after disconnecting. YES means to receive remote push notifications. NO means not to receive remote push notifications.

If the RC server detects that the app client is offline (by default, all devices must be offline), when receiving new messages, the RC server will record an offline message? for the user and trigger the push service on the RC server. The RC server will send a reminder through the push channel to the client SDK. This reminder is usually displayed as a notification in the notification panel, prompting the user of an offline message.

Disconnect (Do Not Allow Push)

Actively disconnect from the RC server-side IM connection and set not to allow the RC server to perform remote push notifications after disconnecting.

When logging out (logging off) or switching app user accounts, it is recommended to use either of the following methods, which have the same effect.

[[RCIMClient sharedRCIMClient] logout];

Or:

[[RCIMClient sharedRCIMClient] disconnect:NO];
ParameterTypeDescription
isReceivePushBOOLWhether to allow the RC server to perform remote push notifications after disconnecting. YES means to receive remote push notifications. NO means not to receive remote push notifications.

When disconnecting and not allowing push notifications, the RC server only records offline messages but does not trigger the push service for the current device. If the user is logged in on multiple devices, the last logged-in device can normally receive push notifications. In a multi-device scenario, the app may need to ensure consistency in message records between devices, which can be achieved by enabling Multi-Device Message Synchronization. See Multi-Device Message Synchronization for details.