Skip to main content

sendMessage

Feature Introduction

Description

Send a message.

Note

You must first call createXXXMessage to create a message. Messages created with createXXXMessageByURL need to be sent using sendMessageNotOss. Related Callbacks: onNewConversation onConversationChanged onRecvNewMessage onRecvNewMessages

Function Prototype


- (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;

Input Parameters

Parameter NameParameter TypeMandatoryDescription
messageOIMMessageInfoYesMessage body
recvIDNSStringNoReceiver's user ID
groupIDNSStringNoReceiver's group ID
offlinePushInfoOIMOfflinePushInfoNoOffline message body

Return Result

NameTypeDescription
onSuccessOIMMessageInfoReturn on success
onProgressNSIntegerSend progress
onFailureOIMFailureCallbackReturn on failure

Code Example


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) {
}];