Disconnect
After connecting to the Nexconn service, call the disconnect: method to disconnect from IM when a user needs to switch accounts or sign out. You can also control whether push notifications are still received after disconnection based on your business requirements.
The SDK automatically reconnects when the app moves between foreground and background, or when a network interruption occurs. Unless your app logic requires a sign-out, you usually don't need to disconnect manually.
Method signature
- Swift
- Objective-C
static func disconnect(disablePush: Bool)
+ (void)disconnect:(BOOL)disablePush;
Parameters
| Parameter | Type | Description |
|---|---|---|
disablePush | BOOL | Whether to disable push notifications after disconnecting. YES disables remote push after disconnect; NO keeps remote push active (default). |
Disconnect and keep push enabled
Use this when the user temporarily leaves but still wants to receive push notifications — for example, when the app goes to the background or the screen is locked.
- Swift
- Objective-C
import NexconnChatSDK
NCEngine.disconnect(disablePush: false)
[NCEngine disconnect:NO];
After disconnection, if the Nexconn server detects that the app client is offline, it will trigger the push service when new messages arrive and deliver notifications to the client via the vendor push channel.
Disconnect and disable push
Use this when signing out or switching app user accounts. Disconnecting with push disabled prevents push notifications from being delivered to the signed-out account.
- Swift
- Objective-C
import NexconnChatSDK
NCEngine.disconnect(disablePush: true)
[NCEngine disconnect:YES];
After disconnecting with push disabled, the Nexconn server only stores offline messages and does not trigger the push service for the current device. If the user is signed in on multiple devices, other active devices are not affected and continue to receive push notifications normally.