Disconnect
After connecting to RC services, when user switching or account logout is required, you can use the following methods to terminate the IM connection with RC. These methods also allow configuration of whether to receive push notifications after disconnection.
The SDK automatically reconnects during foreground/background switching or network exceptions to ensure connection reliability. Manual disconnection is unnecessary unless explicitly required by app logout logic.
Disconnect (Allow Push Notifications)
Actively terminates the IM connection with RC servers while permitting remote push notifications after disconnection. The following two approaches are equivalent:
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| isReceivePush | BOOL | Determines whether to allow RC servers to send remote push notifications after disconnection. YES enables push notifications. NO disables them. |
Sample Code
[[RCCoreClient sharedCoreClient] disconnect];
Or:
[[RCCoreClient sharedCoreClient] disconnect:YES];
When RC servers detect the app client is offline (default requires all devices to be offline), new messages will trigger:
- An offline message? record for the user
- RC server push service activation
If manufacturer push channels (provided by RC) are integrated, the SDK will receive a push notification displayed in the notification panel to alert users about pending messages.
Disconnect (Disallow Push Notifications)
Recommended for logout or account switching scenarios. Actively terminates the IM connection while preventing RC servers from sending remote push notifications. The following approaches are equivalent:
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| isReceivePush | BOOL | Determines whether to allow RC servers to send remote push notifications after disconnection. YES enables push notifications. NO disables them. |
Sample Code
[[RCCoreClient sharedCoreClient] logout];
Or:
[[RCCoreClient sharedCoreClient] disconnect:NO];
When disconnecting with push notifications disabled:
- RC servers still record offline messages
- Push services are not triggered for the current device
- If multiple devices are logged in, the last active device receives push notifications normally
For consistent message history across devices in multi-device scenarios, enable Multi-Device Message Synchronization. See Multi-Device Message Synchronization for details.