Browse SDKs · React Native
Platform
SDKsReact Native

Create audio message from file

Construct an audio voice message from a local file path using the OpenIM React Native SDK.

Copy

Construct an audio message from a local audio file on the device filesystem:

const message = await OpenIMSDK.createSoundMessageFromFullPath({
  soundPath,
  duration: 18,
});

Parameters

ParameterTypeRequiredDescription
soundPathstringYesAbsolute local filesystem path to the audio file.
durationnumberYesAudio 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.