Skip to content

Commit 8e944d7

Browse files
committed
docs(uniapp): align English message guides with Wasm
1 parent 05027c3 commit 8e944d7

60 files changed

Lines changed: 1087 additions & 309 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

content/docs/chat/sdk/uniapp/file-uploads/upload-file.mdx

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,67 @@ platform: 'uniapp'
1111
sourcePath: '/sdk/uniapp/file-uploads/upload-file'
1212
---
1313

14+
`uploadFile()` is an independent upload operation for avatars, group images, profile attachments, and other business files. It does not create a chat message. It uploads a native-readable local file and returns its URL/URI, UUID, size, and media metadata.
15+
16+
## Parameters
17+
18+
| Parameter | Type | Required | Description |
19+
| --- | --- | --- | --- |
20+
| `filepath` | `string` | Yes | Full local path readable by the native layer. |
21+
| `name` | `string` | Yes | Filename. |
22+
| `contentType` | `string` | Yes | MIME type. |
23+
| `uuid` | `string` | Yes | Stable task ID created by your application. |
24+
| `cancelID` | `string` or `null` | No | Stable ID used to cancel this upload. |
25+
| `cause` | `string` or `null` | No | Business purpose or reason for the upload. |
26+
27+
Register the progress event before calling `uploadFile()` so a small file cannot complete before the listener exists.
28+
1429
```uts
15-
import { uploadFile } from '@/uni_modules/unix-openim-sdk'
30+
import { off, onUploadFileProgress, uploadFile } from '@/uni_modules/unix-openim-sdk'
31+
32+
const progressSubscription = onUploadFileProgress((event) => {
33+
if (event == null) return
34+
updateUploadProgress(event.progress)
35+
})
1636
1737
const result = await uploadFile({
18-
filepath: '/data/user/0/app/cache/report.pdf', name: 'report.pdf',
19-
contentType: 'application/pdf', uuid: createStableUploadUUID(), cancelID: 'upload-report-1',
38+
filepath: '/data/user/0/app/cache/report.pdf',
39+
name: 'report.pdf',
40+
contentType: 'application/pdf',
41+
uuid: createStableUploadUUID(),
42+
cancelID: 'upload-report-1',
2043
})
44+
45+
function removeUploadListener() {
46+
off(progressSubscription)
47+
}
2148
```
2249

23-
Use a readable absolute native path. Resolve `unifile://` first and never pass a network URL as `filepath`. Observe progress through `onUploadFileProgress`.
50+
Resolve `unifile://` to a platform sandbox path and never pass a network URL as `filepath`. Android and iOS temporary directories, grants, and lifetimes differ; do not move or delete the source while native code may still read it.
51+
52+
The Promise resolves to `OpenIMUploadFileResult | null`:
53+
54+
| Field | Type | Description |
55+
| --- | --- | --- |
56+
| `url` | `string` or `null` | Uploaded remote URL. |
57+
| `uri` | `string` or `null` | Resource URI returned by the server. |
58+
| `uuid` | `string` or `null` | Upload task identifier. |
59+
| `size` | `number` or `null` | File size. |
60+
| `typ` | `number` or `null` | Resource type returned by the server. |
61+
| `mediaID` | `string` or `null` | Media resource ID. |
62+
63+
Use `result?.url` in a profile update or when creating the appropriate message. Upload success does not update profile data or create/send a chat message; those are separate operations.
64+
65+
## Listen for upload progress
66+
67+
`onUploadFileProgress` returns an `OpenIMSDKEventSubscription`, and its event contains only `progress`. Unlike Wasm completion events, the current uni-app / uni-app x contract does not include a task ID. Do not correlate several concurrent uploads by array position; limit concurrency or track final state through each Promise. Call `removeUploadListener()` when the account or upload store is disposed.
68+
69+
Commercial applications can cancel the matching task with `cancelUpload()` <span className="enterprise-field-badge">Commercial</span>:
2470

2571
```uts
2672
import { cancelUpload } from '@/uni_modules/unix-openim-sdk'
2773
2874
await cancelUpload({ cancelID: 'upload-report-1' })
2975
```
3076

31-
`cancelUpload()` is <span className="enterprise-field-badge">Commercial</span>. The original upload Promise defines the final state. Do not delete a temporary file while native code may still read it.
77+
Cancellation is asynchronous; the original upload Promise and error code define the final state. Do not delete a temporary file until the upload completes or cancellation is confirmed.

content/docs/chat/sdk/uniapp/getting-started/install-initialize-and-inspect-sdk.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ Use `OpenIMPlatformIOS` with `systemType: 'ios'`, or `OpenIMPlatformHarmony` wit
4141
| `platformID` | `OpenIMPlatform` | One of the exported platform constants. |
4242
| `apiAddr` | `string` | OpenIMServer HTTP API address. |
4343
| `wsAddr` | `string` | OpenIMServer WebSocket address. |
44-
| `dataDir` | `string \| null` (optional) | Core data directory; normally use the platform default. |
45-
| `logFilePath` | `string \| null` (optional) | Log path following the platform artifact contract. |
44+
| `dataDir` | `string` or `null` (optional) | Core data directory; normally use the platform default. |
45+
| `logFilePath` | `string` or `null` (optional) | Log path following the platform artifact contract. |
4646
| `logLevel` | `OpenIMLogLevel` | For example `OpenIMLogLevelError` or `OpenIMLogLevelInfo`. |
4747
| `isLogStandardOutput` | `boolean` | Whether SDK logs are emitted to the system console. |
4848
| `systemType` | `string` | Required system description; never omit it. |

content/docs/chat/sdk/uniapp/getting-started/update-token-and-observe-sdk-session.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const snapshot : OpenIMSDKSessionSnapshot = await getSDKSessionSnapshot()
2222
| Field | Type | Description |
2323
| --- | --- | --- |
2424
| `loginStatus` | `OpenIMLoginStatus` | Current login state. |
25-
| `userID` | `string \| null` | Current SDK user, or `null` when logged out. |
25+
| `userID` | `string` or `null` | Current SDK user, or `null` when logged out. |
2626
| `sdkSessionEpoch` | `number` | Session generation, incremented after successful lifecycle or account changes. |
2727
| `sdkVersion` | `string` | Version of the connected Core. |
2828

content/docs/chat/sdk/uniapp/message/composing-messages/check-speech-to-text.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,16 @@ import { getSpeechToTextCapabilities } from '@/uni_modules/unix-openim-sdk'
1717
const capabilities = await getSpeechToTextCapabilities()
1818
```
1919

20-
This <span className="enterprise-field-badge">Commercial</span> query should gate transcription UI. Capability can vary by deployment and account; do not infer it solely from plugin version.
20+
This is a <span className="enterprise-field-badge">Commercial</span> capability query. The Promise resolves to `OpenIMSpeechToTextCapabilitiesResult | null`:
21+
22+
| Field | Type | Description |
23+
| --- | --- | --- |
24+
| `format` | `string[]` or `null` | Supported audio formats. |
25+
| `sampleRateHz` | `number[]` or `null` | Supported sample rates in hertz. |
26+
| `maxRecordTimeMs` | `number` or `null` | Maximum recording duration in milliseconds. |
27+
| `maxFileSize` | `number` or `null` | Maximum file size in bytes. |
28+
| `provider` | `string` or `null` | Current speech-recognition provider. |
29+
| `requestType` | `string` or `null` | Request type required by the service. |
30+
| `crossDomain` | `boolean` or `null` | Whether cross-domain processing is allowed. |
31+
32+
Query and cache capabilities for the current login session before displaying transcription UI. Validate format, sample rate, duration, and size before sending audio. Capabilities can vary by service, language, and account, so refresh them after login changes. Disable transcription on failure instead of guessing limits. This query does not emit message events.

content/docs/chat/sdk/uniapp/message/composing-messages/get-typing-status.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sourcePath: '/sdk/uniapp/message/composing-messages/get-typing-status'
1414
```uts
1515
import { getInputStates } from '@/uni_modules/unix-openim-sdk'
1616
17-
const state = await getInputStates(conversationID)
17+
const result = await getInputStates({ conversationID, userID: peerUserID })
1818
```
1919

20-
This <span className="enterprise-field-badge">Commercial</span> snapshot can become stale quickly. Combine it with typing events and a local timeout; never use it for authorization or durable presence.
20+
`getInputStates()` is a <span className="enterprise-field-badge">Commercial</span> snapshot query. Typing state is a short-lived hint, not a durable business fact. Update the UI from events and apply a local expiry timeout so a disconnect cannot leave “typing” visible forever. Never use this snapshot for authorization or durable presence.

content/docs/chat/sdk/uniapp/message/composing-messages/save-local-transcript.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sourcePath: '/sdk/uniapp/message/composing-messages/save-local-transcript'
1414
```uts
1515
import { setMessageLocalContent } from '@/uni_modules/unix-openim-sdk'
1616
17-
await setMessageLocalContent({ conversationID, clientMsgID, content: transcript })
17+
await setMessageLocalContent({ conversationID, message: updatedMessage })
1818
```
1919

20-
This <span className="enterprise-field-badge">Commercial</span> local-only value is device state and does not edit the server message. Version any structured content and avoid storing unnecessary sensitive transcript data.
20+
`setMessageLocalContent()` is <span className="enterprise-field-badge">Commercial</span> and stores a complete message object in the specified conversation's local database. Merge the transcript into a copy of the original message first; do not overwrite its `clientMsgID`, routing fields, or unrelated business elems. The change is device-local and must not be treated as a server or multi-device edit. Version structured transcript data and avoid retaining unnecessary sensitive content.

content/docs/chat/sdk/uniapp/message/composing-messages/transcribe-audio.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ sourcePath: '/sdk/uniapp/message/composing-messages/transcribe-audio'
1414
```uts
1515
import { speechToText } from '@/uni_modules/unix-openim-sdk'
1616
17-
const result = await speechToText(soundMessage)
17+
const result = await speechToText({
18+
filename: 'voice.m4a',
19+
data: audioBase64,
20+
})
21+
if (result?.text != null) setTranscript(result.text)
1822
```
1923

20-
This is <span className="enterprise-field-badge">Commercial</span>. Use a complete sound message, expose consent/privacy behavior, and store the returned transcript according to product policy rather than modifying the original media.
24+
This is <span className="enterprise-field-badge">Commercial</span>. Native files cannot cross the UTS boundary directly; encode the audio as the commercial service protocol requires. The Promise resolves to `OpenIMSpeechToTextResult | null`, whose optional `text` field contains the transcript.
25+
26+
First query [speech-to-text capabilities](/sdk/uniapp/message/composing-messages/check-speech-to-text) and enforce the supported size, format, sample rate, and duration. Do not log complete audio or Base64 content. Transcription neither edits the original audio message nor emits message events. Ask the user to confirm transcripts before high-risk use; to persist one locally, see [Save a local transcript](/sdk/uniapp/message/composing-messages/save-local-transcript).

content/docs/chat/sdk/uniapp/message/composing-messages/update-typing-status.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ platform: 'uniapp'
1111
sourcePath: '/sdk/uniapp/message/composing-messages/update-typing-status'
1212
---
1313

14-
`changeInputStates()` updates typing/input state; commercial `typingStatusUpdate()` provides the legacy compatible route. Receive updates through `onConversationUserInputStatusChanged`.
14+
Pass `focus: true` when the user starts typing. Pass `false` after sending, when the input loses focus, when switching conversations, or when typing stops. Typing state belongs to `conversationID`; it neither saves a draft nor writes a message.
1515

1616
```uts
1717
import { changeInputStates, off, onConversationUserInputStatusChanged } from '@/uni_modules/unix-openim-sdk'
1818
19-
const typingSubscription = onConversationUserInputStatusChanged((state) => renderTyping(state))
20-
await changeInputStates({ conversationID, focus: true })
19+
const typingSubscription = onConversationUserInputStatusChanged((status) => {
20+
updateConversationInputStatus(status)
21+
})
22+
await changeInputStates({ conversationID, userID: peerUserID, focus: true })
2123
off(typingSubscription)
2224
```
2325

24-
Debounce high-frequency UI changes and expire stale indicators locally.
26+
Report `true` when the input gains focus and `false` on blur or page exit, and throttle high-frequency changes. Commercial compatibility method `typingStatusUpdate()` <span className="enterprise-field-badge">Commercial</span> uses `recvID` and `msgTip`; do not call both routes for one typing flow. Expire stale indicators locally.
27+
28+
Deduplicate state changes instead of reporting every keyboard event. Promise completion only means the request was accepted; it does not mean a remote interface has already updated. This page is the sole owner of `onConversationUserInputStatusChanged`. Replace the current `platformIDs` snapshot by `conversationID:userID`, and call `off(typingSubscription)` when the component, login, or account scope ends.

content/docs/chat/sdk/uniapp/message/creating-messages/create-card-message.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,26 @@ platform: 'uniapp'
1111
sourcePath: '/sdk/uniapp/message/creating-messages/create-card-message'
1212
---
1313

14+
## Parameters
15+
16+
`createCardMessage()` accepts `OpenIMCardElem`. Its fields are nullable in the contract, but a useful card should provide a complete snapshot:
17+
18+
| Parameter | Type | Recommendation | Description |
19+
| --- | --- | --- | --- |
20+
| `userID` | `string` or `null` | Required | User represented by the card. |
21+
| `nickname` | `string` or `null` | Required | Display name snapshot. |
22+
| `faceURL` | `string` or `null` | Required | Avatar URL snapshot. |
23+
| `ex` | `string` or `null` | Required | Extension data; use an empty string when unused. |
24+
1425
```uts
1526
import { createCardMessage } from '@/uni_modules/unix-openim-sdk'
1627
17-
const message = await createCardMessage({ userID: 'user_b', nickname: 'Alice', faceURL: 'https://cdn.example.com/alice.png', ex: '' })
28+
const message = await createCardMessage({
29+
userID: 'user_b',
30+
nickname: 'Alex',
31+
faceURL: 'https://example.com/avatar.png',
32+
ex: '',
33+
})
1834
```
1935

20-
A card is a send-time snapshot. Resolve current profile data by `userID` when opened, and never treat card fields as authenticated identity.
36+
The Promise creates `OpenIMMessageItem | null` and does not send it. A card is a send-time snapshot and does not track profile changes. Resolve current data by `userID` when opened, and never treat card fields as authenticated identity.

content/docs/chat/sdk/uniapp/message/creating-messages/create-custom-message.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,28 @@ platform: 'uniapp'
1111
sourcePath: '/sdk/uniapp/message/creating-messages/create-custom-message'
1212
---
1313

14+
Use `createCustomMessage()` for orders, tasks, invitations, polls, or other business messages whose schema is shared by sender and receiver.
15+
16+
## Parameters
17+
18+
| Parameter | Type | Required | Description |
19+
| --- | --- | --- | --- |
20+
| `data` | `string` | Yes | Complete business payload, normally serialized JSON. |
21+
| `extension` | `string` | Yes | Complete business extension string. |
22+
| `descriptionText` | `string` | Yes | Type description or fallback text for unsupported clients. |
23+
1424
```uts
1525
import { createCustomMessage } from '@/uni_modules/unix-openim-sdk'
1626
1727
const message = await createCustomMessage({
18-
data: JSON.stringify({ orderID: 'order_123' }), extension: '', descriptionText: 'Order card',
28+
data: JSON.stringify({ type: 'task', taskID: 'task_42' }),
29+
extension: JSON.stringify({ schemaVersion: 1 }),
30+
descriptionText: 'Task card',
1931
})
2032
```
2133

22-
All fields reach the recipient. Version and validate a shared schema and store no secrets. `createAdvancedTextMessage()` creates entity/styled text; reject entity ranges outside the original text.
34+
All three fields reach the recipient. Never store secrets; validate schema version, size, and fields before mapping to a business model, and never execute untrusted content. The uni-app / uni-app x contract does not include the Wasm commercial `searchText` parameter. The Promise creates `OpenIMMessageItem | null`; sending and custom business events are separate flows.
35+
36+
## Advanced text messages
37+
38+
`createAdvancedTextMessage()` creates entity/styled text from `OpenIMCreateAdvancedTextMessageParams`. Entity ranges must refer to indexes in the original text; reject out-of-range values before calling the SDK. Both APIs only create messages.

0 commit comments

Comments
 (0)