Before you start
Prepare OpenIMServer, user credentials, and a Flutter runtime before authenticating or sending messages.
Before integrating OpenIMClientSDK into a Flutter app, prepare an accessible OpenIMServer deployment, a trusted user-authentication flow, 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:
| Field | Description |
|---|---|
apiAddr | The OpenIMServer HTTP API address used for login, synchronization, and resource requests. |
wsAddr | The 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. A trusted backend must create or associate users, issue tokens, and enforce application permissions. The Flutter client must never store an administrator token, secret, or other server-side credential.
Before connecting your backend to the OpenIMServer REST API, see Prepare to use the Platform API and Issue a session token. After authenticating the application's account, your backend should return only the minimum data required for SDK 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 correspond to the token. The client must not accept an arbitrary user ID and then issue or assemble a token itself.
Prepare the Flutter project
The pinned SDK version supports Android and iOS. Before integrating it, confirm that:
- The Flutter and Dart versions satisfy the package's
pubspec.yamlconstraints. - 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 product defines behavior for foreground and background transitions, network recovery, token expiration, and multi-device login.
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.
Was this page helpful?