Disconnect
After connecting to RC services, you can use the following methods to disconnect from RC Chat when user switching or account logout is required. These methods also allow you to configure whether to receive push notifications after disconnection.
The IMKit SDK automatically reconnects during app state changes (foreground/background) or network exceptions, ensuring connection reliability. Manual disconnection is only necessary for explicit logout scenarios.
Disconnect (Allow Push Notifications)
Actively disconnects from RC server while permitting remote push notifications after disconnection.
IMCenter.getInstance().disconnect();
When RC server detects the client is offline (default threshold: all devices offline), it stores an offline message? and triggers push services. The server delivers a notification via push channels, typically displayed in the notification panel to alert users about pending messages.
Disconnect (Block Push Notifications)
Actively disconnects from RC server while blocking remote push notifications after disconnection.
Recommended for logout or account switching scenarios:
IMCenter.getInstance().logout();
In this mode, RC server stores offline messages but won't trigger push notifications for the current device. If the user is logged in on multiple devices, the last logged-in device will receive push notifications normally. For multi-device message consistency, enable Multi-Device Message Synchronization. See Multi-Device Message Synchronization for details.