Browse SDKs · iOS
Platform
SDKsiOS

Create an audio message from a local path

Create an audio message from an absolute path with OpenIM iOS SDK.

Copy

Invoke createSoundMessageFromFullPath:duration: on OIMMessageInfo to construct an audio message from an absolute file path in the local application sandbox. The SDK automatically uploads the audio file to object storage during message dispatch:

Parameters

ParameterTypeRequiredDescription
soundPathNSString *YesAbsolute path to the audio file within the application sandbox.
durationNSIntegerYesAudio playback duration in seconds.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createSoundMessageFromFullPath:audioURL.path
                                          duration:durationSeconds];

Return value

Returns an initialized OIMMessageInfo model with its content type set to audio.

State changes after the call

  1. Local memory instantiation: This method builds an in-memory message model without persisting records to local storage or initiating network uploads immediately.
  2. Subsequent dispatch: Call Send a message to execute file upload and deliver the message. If the audio file is already uploaded to remote storage, use Create an audio message from a URL.