Message management
ChatUI updates lists as messages flow. To keep UI and engine state aligned, prefer ChatUI’s sendMessage / insertMessage instead of bypassing ChatUI with low-level send APIs unless you understand the UI impact.
Call both sendMessage and insertMessage after app.ready(). If you call them earlier, the SDK returns NCChatUICode.CHATUI_NOT_READY (39001).
Limits
Typical constraints (confirm per release):
- Upload size caps for images and files follow console and SDK guidance.
- Oversized GIFs may downgrade to file messages.
- Short video duration caps apply.
Send a message
Use sendMessage on NCChatUIApplication: first argument is a channel identifier, second is a SendMessageParams subtype from @nexconn/chat (for example SendTextMessageParams).
import {
DirectChannelIdentifier,
SendTextMessageParams,
} from '@nexconn/chat';
const result = await app.sendMessage(
new DirectChannelIdentifier('peerUserId'),
new SendTextMessageParams({ text: 'Hello' }),
);
if (!result.isOk) {
console.error('send failed', result.code);
}
See Nexconn Chat docs for additional message types.
Insert a message
insertMessage inserts a Message instance wrapped by ChatUIMessageModel into the current UI (for example placeholders or replay data). Persistence rules follow the platform.
import {
DirectChannelIdentifier,
Helper,
SendTextMessageParams,
} from '@nexconn/chat';
const message = Helper.createMessage(
new DirectChannelIdentifier('peerUserId'),
new SendTextMessageParams({ text: 'Local message' }),
);
message.sentTime = Date.now();
const result = await app.insertMessage(message);
Web caching differs from desktop shells; reloading may drop data that existed only locally—validate against your product requirements.