Browse SDKs · Flutter
Platform
SDKsFlutter

Before you start

Prepare your OpenIMServer instance, user credentials, and Flutter environment before authenticating or sending messages.

Copy

Before integrating the OpenIM Flutter SDK into your Flutter app, prepare an accessible OpenIMServer deployment, valid user sign-in credentials, and configured Android or iOS development environments. These prerequisites apply to both Authenticate and manage session and Send your first message.

Prepare OpenIMServer

If you do not have an active OpenIMServer instance, deploy one via Docker deployment. Ensure your target mobile devices can connect to the following endpoints:

EndpointDescription
apiAddrOpenIMServer HTTP API endpoint used for authentication, data synchronization, and media uploads.
wsAddrOpenIMServer WebSocket endpoint used for persistent bidirectional connections and real-time events.

Do not verify endpoints solely on your development workstation. Verify DNS resolution, TLS certificates, firewall rules, reverse proxy settings, and WebSocket upgrade handshakes directly from physical devices or emulators. Production deployments must use HTTPS and WSS protocols.

Prepare user credentials and token

The userID uniquely identifies a user within OpenIM, and the token authenticates that user session. Your business backend creates or associates user accounts and supplies matching userID and token pairs to your Flutter client.

Refer to API preparation and Get user token to integrate your backend with the OpenIMServer REST API. The Flutter SDK requires the following parameters at login:

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 match the subject in the token; otherwise, login fails.

Prepare the Flutter project

The Flutter SDK supports Android and iOS. Verify the following prerequisites:

  • Flutter and Dart SDK versions satisfy the constraints declared in flutter_openim_sdk's pubspec.yaml.
  • Android and iOS project files include network permissions, meet minimum OS target versions, and conform to SDK build requirements.
  • An application data directory is prepared. Use path_provider to retrieve a persistent application documents directory; avoid temporary or shared cache paths.
  • Physical devices can reach apiAddr, wsAddr, and object storage domains hosting message media.
  • Your application handles foreground/background transitions, network reconnects, token expiration, and multi-device kick-out events.

For platform initialization specifics, see Environment-specific implementation.

Next steps

After completing environment setup, proceed to Authenticate and manage session. Once login succeeds and OnConnectListener.onConnectSuccess fires, proceed to Send your first message to verify the messaging pipeline.