Disconnect
Disconnect from the server when the user switches accounts or logs out. Specify whether the user should continue to receive push notifications after disconnecting.
tip
The SDK automatically reconnects when switching between foreground/background or when network issues occur. Only call this method when your app logic requires a logout.
Method
Dart
static Future<int> disconnect({bool disablePush = false})
Parameters
| Parameter | Type | Description |
|---|---|---|
disablePush | bool | Whether to disable push notifications after disconnecting. false (default) — continue receiving push notifications. true — stop receiving push notifications. |
Return value
| Return value | Description |
|---|---|
Future<int> | Status code for the API call. 0 means the call succeeded. Non-zero means the call failed. See error codes for details. |
Code example
Dart
// Disconnect and keep push notifications enabled (default)
await NCEngine.disconnect();
// Disconnect and disable push notifications
await NCEngine.disconnect(disablePush: true);