Streaming Messages
Starting from version 5.16.1, IMKit supports built-in streaming messages for continuous reception of server messages.


Limitations
The streaming message feature currently has the following restrictions:
- The maximum content length for a message is 10,000 characters.
- Only supports streaming message reception for one-to-one and group chats.
Content Display
Streaming messages support Markdown, Text, and HTML formats. For specific field values, refer to Streaming Messages. HTML format support was added in version 5.20.0.
For HTML format, pay attention to the following details. SDKs for Markdown and Text formats do not require this.
Content Security
IMKit SDK uses the native WKWebView
component to load HTML-type streaming messages but does not process the content. Developers must ensure content security.
Developers can embed CSP tags in HTML to enhance security.
CSP
is part of HTML and must be processed by the application server before being sent to RC servers. Use AI model formatting and system prompts to add specific content.
Sample Code
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; img-src 'self';">
<!-- Other content -->
</head>
<body>
<!-- Page content -->
</body>
</html>
Dark Mode
IMKit SDK adapts WKWebView themes using the CSS rule prefers-color-scheme
, but this has system version limitations on mobile devices and depends on app theme settings.
- iOS 13 and above: iOS IMKit supports dark mode. If HTML content includes
prefers-color-scheme
, IMKit and WKWebView will automatically follow light/dark themes. - Below iOS 13: Not supported.
prefers-color-scheme
is part of HTML and must be processed by the developer's AppServer before being sent to RC servers. Use AI model formatting and system prompts to add specific content.
Sample Code
@media (prefers-color-scheme: dark) {
.day.dark-scheme {
background: #333;
color: white;
}
.night.dark-scheme {
background: black;
color: #ddd;
}
}
@media (prefers-color-scheme: light) {
.day.light-scheme {
background: white;
color: #555;
}
.night.light-scheme {
background: #eee;
color: black;
}
}