跳到主要内容

sendMessage

功能介绍

说明

发送消息。

注意

需要先调用createXXXMessage创建一条消息,createXXXMessageByURL创建的消息需要通过sendMessageNotOss发送。
相关回调
onNewConversation
onConversationChanged
onRecvNewMessage
onRecvNewMessages

函数原型


- (void)sendMessage:(OIMMessageInfo *)message
recvID:(NSString * _Nullable)recvID
groupID:(NSString * _Nullable)groupID
offlinePushInfo:(OIMOfflinePushInfo * _Nullable)offlinePushInfo
onSuccess:(nullable OIMMessageInfoCallback)onSuccess
onProgress:(nullable OIMNumberCallback)onProgress
onFailure:(nullable OIMFailureCallback)onFailure;

输入参数

参数名称参数类型是否必填描述
messageOIMMessageInfo消息体
recvIDNSSting接收消息的 user ID
groupIDNSSting接收消息的 group ID
offlinePushInfoOIMOfflinePushInfo离线消息体

返回结果

名称类型描述
onSuccessOIMMessageInfo成功返回
onProgressNSInteger发送进度
onFailureOIMFailureCallback失败返回

代码示例


OIMMessageInfo *testMessage = [OIMMessageInfo createTextMessage:@"test"];

[OIMManager.manager sendMessage:testMessage
recvID:@""
groupID:@""
offlinePushInfo:nil
onSuccess:^(OIMMessageInfo * _Nullable message) {
} onProgress:^(NSInteger number) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];