这里是官方的文档:
发送音频消息
发送音频消息的基本流程是:读取音频文件(或者录制音频)> 构建音频消息 > 消息发送。
- (void)tomSendAudioToJerry {
// Tom 创建了一个 client,用自己的名字作为 clientId
self.client = [[AVIMClient alloc] initWithClientId:@"Tom"];
// Tom 打开 client
[self.client openWithCallback:^(BOOL succeeded, NSError *error) {
// Tom 建立了与 Jerry 的会话
[self.client createConversationWithName:@"猫和老鼠" clientIds:@[@"Jerry"] callback:^(AVIMConversation *conversation, NSError *error) {
// Tom 发了一首歌曲给 Jerry
NSString *path = [[NSBundle mainBundle] pathForResource:@"忐忑" ofType:@"mp3"];
AVFile *file = [AVFile fileWithName:@"忐忑.mp3" contentsAtPath:path];
AVIMImageMessage *message = [AVIMImageMessage messageWithText:@"听听人类的神曲~" file:file attributes:nil];
[conversation sendMessage:message callback:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"发送成功!");
}
}];
}];
}];
}
-
创建时间
17年4月14日
-
最后回复
17年5月31日
-
7
回复
-
1.5K
浏览
-
2
用户