SDKsReact Native
Create audio message from file
Construct an audio voice message from a local file path using the OpenIM React Native SDK.
Construct an audio message from a local audio file on the device filesystem:
const message = await OpenIMSDK.createSoundMessageFromFullPath({
soundPath,
duration: 18,
});Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
soundPath | string | Yes | Absolute local filesystem path to the audio file. |
duration | number | Yes | Audio playback duration in seconds. |
Return value
A resolved Promise returns the initialized MessageItem object with audio properties populated in soundElem.
This method builds the message structure strictly in client memory; it does not dispatch messages to the server or trigger lifecycle events. After initialization, invoke Send message to deliver it to a conversation; the SDK automatically uploads the local audio file during transmission.
Was this page helpful?