Browse SDKs · iOS
Platform
SDKsiOS

Create an audio message from a URL

Create an audio message from a previously uploaded URL with OpenIM iOS SDK.

Copy

When the application has already uploaded audio recordings to an external server or object storage, invoke createSoundMessageByURL:duration:size: on OIMMessageInfo to construct an audio message object directly without redundant uploads by the SDK:

Parameters

ParameterTypeRequiredDescription
soundURLNSString *YesAccessible remote URL of the uploaded audio file.
durationNSIntegerYesAudio playback duration in seconds.
sizeNSIntegerYesActual size of the audio file in bytes.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createSoundMessageByURL:uploadedURL
                                   duration:durationSeconds
                                       size:uploadedSize];

Return value

Returns an initialized OIMMessageInfo model populated with the remote audio URL and metadata. The passed URL, duration, and file size must match valid asset data.

State changes after the call

  1. Local memory instantiation: This method constructs an in-memory message object without writing to the database or initiating network activity.
  2. Subsequent dispatch: Because the audio file is already hosted externally, deliver the message by calling Send a message without SDK-managed upload. If you need the SDK to manage local audio uploading, use Create an audio message from a local path.