Skip to main content

Sending Ultra Group Targeted Messages

You can send regular messages and multimedia messages to one or more specified members in an ultra group channel, while other members will not receive these messages.

tip
  • This capability is supported starting from version 5.6.9.
  • The maximum number of recipients for a single targeted message is 300 users.
  • If the targeted message is an @mention message, @all is not supported.

Sending Targeted Regular Messages

You can use sendDirectionalMessage:toUserIdList:pushContent:pushData:attached:successBlock:errorBlock: to send regular messages to specified users in a specific channel of an ultra group. Users not in the recipient list will not receive this message.

Set the ultra group conversation type, ultra group targetId, and channel channelId in the message object. When channelId is empty, messages are sent to the RCDefault channel by default. Note that the recipient userId list is not stored in the RCMessage object.

Method Signature

- (void)sendDirectionalMessage:(RCMessage *)message
toUserIdList:(NSArray<NSString *> *)userIdList
pushContent:(nullable NSString *)pushContent
pushData:(nullable NSString *)pushData
attached:(nullable void(^)(RCMessage *_Nullable message))attachedBlock
successBlock:(nullable void (^)(RCMessage *successMessage))successBlock
errorBlock:(nullable void (^)(RCErrorCode nErrorCode, RCMessage *errorMessage))errorBlock;

Parameter Description

ParameterTypeDescription
messageRCMessageThe message body to be sent. Required attributes include conversation type (conversationType), channel ID (channelId), conversation ID (targetId), and message content (content).
userIdListNSArrayList of recipient users
pushContentNSStringModifies or specifies the content displayed in the remote push notification bar. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Push Notification Attributes].
  • To use RC's default push notification content, set to nil. Note that custom message types have no default value.
  • To specify personalized offline push notifications for this message, you must provide the pushContent field content in either location.
  • If your custom message type requires offline push services, you must provide the pushContent field content in either location; otherwise, users will not receive offline push notifications.
pushDataStringAdditional information for remote push notifications. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Push Notification Attributes].
attachedBlockBlockCallback when the message is successfully inserted into the database
successBlockBlockCallback when the message is successfully sent
errorBlockBlockCallback when message sending fails, including the error code RCErrorCode and the failed message.

Example Code

RCTextMessage *text = [RCTextMessage messageWithContent:@"Hello"];
RCMessage *message = [[RCMessage alloc] initWithType:ConversationType_ULTRAGROUP targetId:@"Group1" direction:MessageDirection_SEND messageId:-1 content:text];

[[RCCoreClient sharedCoreClient] sendDirectionalMessage:message
toUserIdList:@[@"user1",@"user2"]
pushContent:nil
pushData:nil
attached:^(RCMessage * _Nullable message) {

}successBlock:^(RCMessage *successMessage) {

} errorBlock:^(RCErrorCode nErrorCode, RCMessage *errorMessage) {

}];

Sending Targeted Multimedia Messages

You can use sendDirectionalMediaMessage:toUserIdList:pushContent:pushData:attached:progress:successBlock:errorBlock:cancel: to send multimedia messages to specified users in a specific channel of an ultra group. Users not in the recipient list will not receive this message.

Set the ultra group conversation type, ultra group targetId, and channel channelId in the message object. When channelId is empty, messages are sent to the RCDefault channel by default. Note that the recipient userId list is not stored in the RCMessage object.

Method Signature

- (void)sendDirectionalMediaMessage:(RCMessage *)message
toUserIdList:(NSArray<NSString *> *)userIdList
pushContent:(nullable NSString *)pushContent
pushData:(nullable NSString *)pushData
attached:(nullable void(^)(RCMessage *_Nullable message))attachedBlock
progress:(nullable void (^)(int progress, RCMessage *progressMessage))progressBlock
successBlock:(nullable void (^)(RCMessage *successMessage))successBlock
errorBlock:(nullable void (^)(RCErrorCode nErrorCode, RCMessage *errorMessage))errorBlock
cancel:(nullable void (^)(RCMessage *cancelMessage))cancelBlock;

Parameter Description

ParameterTypeDescription
messageRCMessageThe message body to be sent. Required attributes include conversation type (conversationType), channel ID (channelId), conversation ID (targetId), and message content (content).
userIdListNSArrayList of recipient users
pushContentNSStringModifies or specifies the content displayed in the remote push notification bar. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Push Notification Attributes].
  • To use RC's default push notification content, set to nil. Note that custom message types have no default value.
  • To specify personalized offline push notifications for this message, you must provide the pushContent field content in either location.
  • If your custom message type requires offline push services, you must provide the pushContent field content in either location; otherwise, users will not receive offline push notifications.
pushDataStringAdditional information for remote push notifications. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Push Notification Attributes].
attachedBlockBlockCallback when the message is successfully inserted into the database
progressBlockCallback for message sending progress updates
successBlockBlockCallback when the message is successfully sent
errorBlockBlockCallback when message sending fails, including the error code RCErrorCode and the failed message.
cancelBlockCallback when the user cancels message sending

Example Code

RCImageMessage *imageMessage = [RCImageMessage messageWithImageURI:@"https://test.png"];
RCMessage *message = [[RCMessage alloc] initWithType:ConversationType_ULTRAGROUP targetId:@"Group1" direction:MessageDirection_SEND messageId:-1 content:imageMessage];

[[RCCoreClient sharedCoreClient] sendDirectionalMediaMessage:message toUserIdList:@[@"user1",@"user2"] pushContent:nil pushData:nil attached:^(RCMessage * _Nullable message) {

}progress:^(int progress, RCMessage * _Nonnull progressMessage) {
// Multimedia upload progress callback
} successBlock:^(RCMessage * _Nonnull successMessage) {
// Message sent successfully
} errorBlock:^(RCErrorCode nErrorCode, RCMessage * _Nonnull errorMessage) {
// Message sending failed
} cancel:^(RCMessage * _Nonnull cancelMessage) {
// User canceled sending
}];