Disconnect
After connecting to the Nexconn server, call disconnect(disablePush:) to close the IM connection when users switch accounts or log out. You can choose whether to continue receiving push notifications after disconnecting.
The SDK automatically reconnects when switching between foreground/background or when the network recovers. You only need to call disconnect: when your app logic requires a logout.
API reference
- Swift
- Objective-C
import NexconnChatSDK
static func disconnect(disablePush: Bool = false)
+ (void)disconnect:(BOOL)disablePush;
| Parameter | Type | Description |
|---|---|---|
disablePush | BOOL | Whether to disable push notifications after disconnecting. YES: stop receiving push notifications. NO (default): continue receiving push notifications. |
Disconnect and keep push notifications
Use this when the user temporarily leaves but should still receive push notifications (for example, when the app goes to the background or the screen locks):
- Swift
- Objective-C
import NexconnChatSDK
NCEngine.disconnect(disablePush: false)
[NCEngine disconnect:NO];
After disconnecting, if the server detects the client is offline, it triggers push notifications through the device manufacturer's push channel for new messages.
Disconnect and disable push notifications
Use this for logout or account switching to prevent the signed-out account from receiving push notifications:
- Swift
- Objective-C
import NexconnChatSDK
NCEngine.disconnect(disablePush: true)
[NCEngine disconnect:YES];
After disconnecting with push disabled, the server only stores missed messages and does not trigger push notifications for the current device. Other devices where the user is still online are not affected.