Browse SDKs · Flutter
Platform
SDKsFlutter

Before you start

Prepare OpenIMServer, user credentials, and a Flutter runtime before authenticating or sending messages.

Copy

Before integrating OpenIMClientSDK into a Flutter app, prepare an accessible OpenIMServer deployment, user login information, and an Android or iOS project environment. These prerequisites apply to both Authenticate and manage a session and Send your first message.

Prepare OpenIMServer

If you do not yet have an OpenIMServer deployment, follow the Docker deployment guide. Then confirm that the mobile device can reach both endpoints:

FieldDescription
apiAddrThe OpenIMServer HTTP API address used for login, synchronization, and resource requests.
wsAddrThe OpenIMServer WebSocket address used for persistent connections and real-time events.

Do not validate these addresses only from the development computer. Check DNS, TLS certificates, firewall rules, reverse proxies, and WebSocket upgrades from a physical device or emulator as well. Production apps should use HTTPS and WSS.

Prepare the user and token

userID identifies an OpenIMSDK user, while the token authenticates that user. The application backend creates or associates users and supplies the Flutter client with a matching userID and token.

Before connecting your backend to the OpenIMServer REST API, see Prepare to use the Platform API and Issue a session token. Flutter SDK login requires the following data:

class OpenIMSDKSession {
  const OpenIMSDKSession({
    required this.userID,
    required this.token,
    required this.apiAddr,
    required this.wsAddr,
  });

  final String userID;
  final String token;
  final String apiAddr;
  final String wsAddr;
}

The userID must correspond to the token; otherwise, login fails.

Prepare the Flutter project

The Flutter SDK supports Android and iOS. Before integrating it, confirm that:

  • The Flutter and Dart versions satisfy the package's pubspec.yaml constraints.
  • The Android and iOS projects have network permission and meet the SDK's minimum system and build requirements.
  • A persistent SDK data directory is available. You can obtain the app documents directory with path_provider; do not use a temporary or shared directory.
  • Physical devices can reach apiAddr, wsAddr, and the domains that host message media.
  • The application handles foreground and background transitions, network recovery, token expiration, and multi-device login state changes.

For initialization details, see Integrate for each runtime.

Continue the integration

After completing the prerequisites, follow Authenticate and manage a session. Once OnConnectListener.onConnectSuccess has fired, verify the messaging flow with Send your first message.