Skip to main content

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.

tip

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
import NexconnChatSDK
static func disconnect(disablePush: Bool = false)
ParameterTypeDescription
disablePushBOOLWhether 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
import NexconnChatSDK
NCEngine.disconnect(disablePush: false)

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
import NexconnChatSDK
NCEngine.disconnect(disablePush: true)

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.