IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMSoundElem

Instance Methods

(void) - getUrl:
 
(void) - downloadSound:progress:succ:fail:
 
(void) - convertVoiceToText:completion:
 
(V2TIMElem *) - nextElem
 
(void) - appendElem:
 

Properties

NSString * path
 
NSString * uuid
 
int dataSize
 
int duration
 

Method Documentation

◆ getUrl:()

- (void) getUrl: (void(^)(NSString *url))  urlCallBack

Get the voice download URL.

◆ downloadSound:progress:succ:fail:()

- (void) downloadSound: (NSString *)  path
progress: (V2TIMDownLoadProgress)  progress
succ: (V2TIMSucc)  succ
fail: (V2TIMFail)  fail 

Download audio. This API downloads data from the server. To cache or store the data, you can use the UUID as the key. The Chat SDK does not store the files.

Parameters
pathThe path to which the audio file is saved. It must be specified externally.

◆ convertVoiceToText:completion:()

- (void) convertVoiceToText: (NSString *)  language
completion: (void(^)(int code, NSString *desc, NSString *result))  callback 

Convert the voice to text (supported only in 7.4 and later versions).

Parameters
languageThe language of the voice recognized.
Attention
  • Converting voice to text is a paid value-added feature and is now in beta testing. To try the feature, join our Tencent Cloud IM Group.

◆ nextElem()

- (V2TIMElem *) nextElem

Get the next Elem. If your message has multiple Elems, you can get the next Elem object from the current Elem. If the return value is nil, it means the Elem acquisition is over. For detailed usage, please refer to the document Message sending and receiving

◆ appendElem:()

- (void) appendElem: (V2TIMElem *)  elem

Add the next element
To configure multiple elements, after creating a Message object, you can add the next element via the element object of Message. The following is the sample code for creating V2TIMTextElem and V2TIMCustomElem:

    V2TIMMessage *msg = [[V2TIMManager sharedInstance] createTextMessage:"text"];
    V2TIMCustomElem *customElem = [[V2TIMCustomElem alloc] init];
    customElem.data = ["自定义消息" dataUsingEncoding:NSUTF8StringEncoding];
    [msg.textElem appendElem:customElem];
Attention
  • This API can be called only by elements of a Message object created via createMessage.
  • This API can be used to add V2TIMTextElem, V2TIMCustomElem, V2TIMFaceElem, or V2TIMLocationElem.

Property Documentation

◆ path

- (NSString*) path
readnonatomicstrong

The path of the audio file to be sent (can only be called by the message sender)

◆ uuid

- (NSString*) uuid
readnonatomicstrong

The internal ID of a voice message.

◆ dataSize

- (int) dataSize
readnonatomicassign

The voice data size.

◆ duration

- (int) duration
readnonatomicassign

The voice duration (seconds)