Disconnect
When your app needs to switch user accounts or log out, you must disconnect from RC's IM service. The SDK allows configuring whether to enable push notifications after disconnecting.
The SDK automatically reconnects during app foreground/background switches or network exceptions to ensure connection reliability. Manual disconnection is only required for logout operations.
Disconnect (Allow Push)
Actively disconnect from RC's IM service while allowing remote push notifications from the server. These two methods are equivalent:
Parameters
Parameter | Type | Description |
---|---|---|
isReceivePush | BOOL | Whether to allow remote push notifications after disconnection. YES enables push. NO disables push. |
Sample Code
[[RCIM sharedRCIM] disconnect];
Or:
[[RCIM sharedRCIM] disconnect:YES];
When RC server detects the app client is offline (all devices disconnected by default), it will:
- Record an offline message? for new incoming messages
- Trigger push service to deliver a notification via push channels
- Display the notification to alert users about pending messages
Disconnect (Block Push)
For logout or account switching scenarios, use these methods to disconnect while blocking push notifications. These two methods are equivalent:
Parameters
Parameter | Type | Description |
---|---|---|
isReceivePush | BOOL | Whether to allow remote push notifications after disconnection. YES enables push. NO disables push. |
Sample Code
[[RCIM sharedRCIM] logout];
Or:
[[RCIM sharedRCIM] disconnect:NO];
When disconnecting with push disabled:
- RC server still records offline messages
- No push notifications are triggered for the current device
- If the user has multiple logged-in devices, only the last active device receives pushes
For multi-device message consistency, enable Multi-Device Message Synchronization. See Multi-Device Message Synchronization for details.