Sending Messages
This document describes how to use the IMLib SDK to send messages in one-to-one chats, group chats, and chatrooms.
For sending ultra group messages, refer to the ultra group documentation Sending and Receiving Messages.
Message Content Types Overview
The content property of the RCMessage object defined by the IMLib SDK can contain two main types of message content: regular message content and media message content. The parent class for regular message content is RCMessageContent, while the parent class for media message content is RCMediaMessageContent. The interfaces for sending media messages and regular messages differ, with the key distinction being whether there is a media data upload process.
| Feature | Message Content Type | Parent Class | Description |
|---|---|---|---|
| Text Message | RCTextMessage | RCMessageContent | Content of text messages. |
| Quote Reply | RCReferenceMessage | RCMessageContent | Content of quoted messages, used to implement quote reply functionality. |
| Image Message | RCImageMessage | RCMediaMessageContent | Content of image messages, supports sending original images. |
| GIF Message | RCGIFMessage | RCMediaMessageContent | Content of GIF messages. |
| File Message | RCFileMessage | RCMediaMessageContent | Content of file messages. |
| HQ Voice Message | RCHQVoiceMessage | RCMediaMessageContent | Content of high-quality voice messages. |
| Mentions (@ messages) | N/A | N/A | @ messages are not predefined message types. See How to Send @ Messages. |
The above are some of the built-in message content types in the IMLib SDK. You can also create custom message content types. If your custom message is a regular message type, use the sendMessage method; if it's a media message type, use the sendMediaMessage method. For details, see Custom Message Types.
- Use the
sendMessagemethod for regular messages and thesendMediaMessagemethod for media messages.- The client SDK has a message rate limit of 5 messages per second.
Regular Messages
Regular messages refer to text messages, quoted messages, and other messages that do not involve media file uploads. The message content for regular messages is a subclass of RCMessageContent, such as text message content (RCTextMessage) or custom regular message content.
Constructing Regular Messages
Before sending a regular message, you need to construct an RCMessage object by setting the conversation type (one-to-one, group, chatroom), the conversation's Target ID, message direction (send or receive), and message content. The following example constructs a message object containing text message content (RCTextMessage).
The
disableUpdateLastMessageproperty ofRCMessaagecontrols whether the message updates to the conversation's latest message. Default is NO: updates to the conversation's last message; YES: does not update to the conversation's last message.
RCTextMessage *messageContent = [RCTextMessage messageWithContent:@"Test text message"];
RCConversationType conversationType = ConversationType_PRIVATE
RCMessage *message = [[RCMessage alloc]
initWithType:conversationType
targetId:@"targetId"
direction:MessageDirection_SEND
content:messageContent];
Sending Regular Messages
If the message content in the RCMessage object is regular message content, use the sendMessage method of the IMLib SDK's core class RCCoreClient to send the message.
Interface Prototype
- (void)sendMessage:(RCMessage *)message
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;
The sendMessage method directly provides parameters for controlling push notification content (pushContent) and push additional information (pushData). Alternatively, you can use the message push attribute configuration RCMessagePushConfig, which includes pushContent and pushData and offers more push notification configuration capabilities, such as push title, push content, push icon, or other third-party vendor-specific configurations. For details, see Remote Push Notifications.
Regarding whether to configure the pushContent parameter in the sendMessage interface or the pushContent in the RCMessage's messagePushConfig property, refer to the following:
-
If the message type is a [predefined message type of the IM service] in the [user content message format], such as RCTextMessage,
pushContentcan be set tonull. When the message triggers an offline push notification, the remote push notification will use the server's default push notification content. For the default push notification content of each message type, see [User Content Message Format]. -
If the message type is a notification or signaling type in the [predefined message types of the IM service] (except "recall command messages") and needs to support remote push notifications,
pushContentmust be filled in; otherwise, recipients who are offline will not receive remote push notifications. If remote push is not needed, this field can be left blank. -
If the message type is a custom message type, refer to How Custom Messages Support Remote Push.
-
Note that chatroom conversations do not support offline message mechanisms and therefore do not support offline message-to-push conversion.
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| message | RCMessage | The message body to send. Required properties include conversation type (conversationType), conversation ID (targetId), and message content (content). See the structure description of RCMessage in [Message Introduction]. |
| pushContent | NSString | Modify or specify the content displayed in the remote message push notification bar. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Message Push Attributes]. |
| pushData | NSString | Additional push information. Can be set to nil. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Message Push Attributes]. |
| attachedBlock | Block | Callback when the message is successfully stored in the message database. |
| successBlock | Block | Callback when the message is successfully sent. |
| errorBlock | Block | Callback when the message fails to send. |
You can use the callbacks of the sendMessage method of RCCoreClient to confirm whether your message has been successfully sent to the RC server. If the send fails for any reason, you can obtain the returned exception through the callback method.
Example Code
RCTextMessage *messageContent = [RCTextMessage messageWithContent:@"Test text message"];
RCMessage *message = [[RCMessage alloc]
initWithType:ConversationType_PRIVATE
targetId:@"targetId"
direction:MessageDirection_SEND
content:messageContent];
[[RCCoreClient sharedRCCoreClient]
sendMessage:message
pushContent:nil
pushData:nil
attached:^(RCMessage *successMessage) {
// Successfully stored
}
successBlock:^(RCMessage *successMessage) {
// Success
}
errorBlock:^(RCErrorCode nErrorCode, RCMessage *errorMessage) {
// Failure
}];
- For how to customize the remote push notifications received by recipients when offline, see Remote Push Notifications below.
- Custom message types do not support offline message-to-push conversion by default. For support, see How Custom Messages Support Remote Push below.
Media Messages
Media messages refer to images, GIFs, files, and other messages that require media file upload processing. The message content type for media messages is a subclass of RCMeidaMessageContent, such as high-quality voice message content (RCHQVoiceMessage) or your custom media message content.
Constructing Media Messages
Before sending, you need to construct an RCMessage object. The content field of the media message RCMessage object must be passed a subclass object of RCMediaMessageContent, representing media message content. For example, image message content (RCImageMessage), GIF message content (RCGIFMessage), or custom media message content that inherits from RCMediaMessageContent.
To construct an image message, you can use the messageWithImageURI: method by passing a valid local image path to construct image message content (RCImageMessage). Image message content supports sending the original image.
The
disableUpdateLastMessageproperty ofRCMessaagecontrols whether the message updates to the conversation's latest message. Default is NO: updates to the conversation's last message; YES: does not update to the conversation's last message.
RCImageMessage *mediaMessageContent = [RCImageMessage messageWithImageURI:@"path/to/image"];
mediaMessageContent.full YES; // Image messages support sending the original image
RCMessage *message = [[RCMessage alloc] initWithType:ConversationType_PRIVATE
targetId:@"targetId"
direction:MessageDirection_SEND
content:mediaMessageContent];
Before sending, images are compressed in quality and thumbnails are generated for display in the chat UI. GIFs do not have thumbnails and are not compressed.
-
Thumbnails for image messages: The IMLib SDK generates a large image that meets standard size requirements at 30% of the original image quality before uploading and sending. The compressed image's longest side does not exceed 240 px. The thumbnail is used for display in the chat UI.
-
Images: If the original image is not selected for sending, the IMLib SDK generates a large image that meets standard size requirements at 85% of the original image quality before uploading and sending. The compressed image's longest side does not exceed 1080 px.
-
Generally, it is not recommended to modify the IMLib SDK's default image compression configuration. Starting from IMLib SDK version 5.16.1, the SDK includes the RCLocalConfiguration class, which allows configuring image compression quality via the
[RCLocalConfiguration sharedInstance]method. For versions before 5.16.1, refer to the knowledge base article How to Modify the SDK's Default Image and Video Compression Configuration for adjusting the IMLib SDK's image compression quality.
Sending Media Messages
Use the sendMediaMessage method to send media messages. The IMLib SDK generates thumbnails for images, short videos, and other media, compresses them according to the default compression configuration, uploads the media files to RC's default file server (file storage duration), and sends the message after successful upload. If an image message is set to send the original image, it will not be compressed.
Interface Prototype
- (void)sendMediaMessage:(RCMessage *)message
pushContent:(nullable NSString *)pushContent
pushData:(nullable NSString *)pushData
attached:(nullable void(^)(RCMessage * _Nullable message))attachedBlock
uploadPrepare:(nullable void (^)(RCUploadMediaStatusListener *uploadListener))uploadPrepareBlock
progress:(nullable void (^)(int progress, long messageId))progressBlock
success:(nullable void (^)(long messageId))successBlock
error:(nullable void (^)(RCErrorCode errorCode, long messageId))errorBlock
cancel:(nullable void (^)(long messageId))cancelBlock;
The sendMediaMessage method directly provides parameters for controlling push notification content (pushContent) and push additional information (pushData). Alternatively, you can use the message push attribute configuration RCMessagePushConfig, which includes pushContent and pushData and offers more push notification configuration capabilities, such as push title, push content, push icon, or other third-party vendor-specific configurations. For details, see Remote Push Notifications.
Regarding whether to configure the pushContent parameter in the sendMediaMessage interface or the pushContent in the RCMessage's messagePushConfig property, refer to the following:
-
If the message type is a [predefined message type of the IM service] in the [user content message format], such as RCImageMessage,
pushContentcan be set tonil. When the message triggers an offline push notification, the remote push notification will use the server's default push notification content. For the default push notification content of each message type, see [User Content Message Format]. -
If the message type is a custom message type, refer to How Custom Messages Support Remote Push.
-
Note that chatroom conversations do not support offline message mechanisms and therefore do not support offline message-to-push conversion.
Parameter Description
| Parameter | Type | Description |
|---|---|---|
| message | RCMessage | The message body to send. Required properties include conversation type (conversationType), conversation ID (targetId), and message content (content). See the structure description of RCMessage in [Message Introduction]. |
| pushContent | NSString | Modify or specify the content displayed in the remote message push notification bar. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Message Push Attributes]. |
| pushData | NSString | Additional push information. Can be set to nil. You can also configure this in the push attributes (RCMessagePushConfig) of RCMessage, which will override this setting. See [Configuring Message Push Attributes]. |
| attachedBlock | Block | Callback when the message is successfully stored in the message database. |
| progressBlock | Block | Callback for media upload progress. |
| successBlock | Block | Callback when the message is successfully sent. |
| errorBlock | Block | Callback when the message fails to send. |
| cancel | Block | Callback when sending is canceled. |
Sample Code
[[RCCoreClient sharedCoreClient] sendMediaMessage:message
pushContent:nil
pushData:nil
attached:^(RCMessage *successMessage) {
//Message successfully stored in database
}
progress:^(int progress, RCMessage *progressMessage) {
//Media upload progress
}
successBlock:^(RCMessage *successMessage) {
//Success
}
errorBlock:^(RCErrorCode nErrorCode, RCMessage *errorMessage) {
//Failure
}
cancel:^(RCMessage *cancelMessage) {
//Cancellation
}];
Through the callback methods of RCCoreClient's sendMediaMessage method, the RC server will always notify the media file upload progress and whether your message has been successfully sent. If sending fails due to any issue, the exception will also be returned via callback methods.
The media message sending method defaults to uploading media files to RC's file server. You can download media message files in your client application. RC imposes size limits on uploaded media files: GIFs are limited to 2 MB, while file uploads are capped at 100 MB. If you need to increase the GIF file size limit, you can [submit a ticket], but the file upload limit cannot be adjusted.
- For how to customize offline remote push notifications for recipients, see Remote Notifications below.
- Custom message types do not support offline message-to-push mechanism by default. For enabling support, see How Custom Messages Support Remote Push below.
Sending Media Messages Uploaded to Your Own Server
You can directly send files already hosted on your server. Pass the media file's URL (indicating its location) as a parameter when constructing the media message content. In this case, your files won't be hosted on RC servers. When sending file messages with remote URLs, there are no size restrictions, and you can directly use the sendMessage method to send the message.
If you want the SDK to send the message after your upload succeeds, you can use the sendMediaMessage method of RCCoreClient as follows:
- Call the
sendMediaMessage:interface to send media messages. During media file upload, you can callupdateBlockanderrorBlockof RCUploadMediaStatusListener to notify the IMLib SDK of the current upload progress and status. - After upload completes, obtain the network file URL. Get the current
RCMessageobject via thecurrentMessageproperty of RCUploadMediaStatusListener, then set the corresponding URL field in thecontentof theRCMessageobject to the successfully uploaded network file URL. - Call the
successBlockof RCUploadMediaStatusListener to notify the IMLib SDK that file upload is complete.
RCImageMessage *mediaMessageContent = [RCImageMessage messageWithImageURI:@"path/to/image"];
mediaMessageContent.full = YES; // Image messages support sending as original image
RCMessage *message = [[RCMessage alloc]
initWithType:ConversationType_PRIVATE
targetId:@"targetId"
direction:MessageDirection_SEND
content:mediaMessageContent];
[[RCCoreClient sharedCoreClient] sendMediaMessage:message
pushContent:nil
pushData:nil
attached:^(RCMessage * _Nullable msg) {
} uploadPrepare:^(RCUploadMediaStatusListener * _Nonnull uploadListener) {
RCMessage *currentMessage = uploadListener.currentMessage;
// When uploading media files, the app needs to call updateBlock, successBlock, and errorBlock in the listener
if ([currentMessage.content isKindOfClass:[RCImageMessage class]]) {
RCImageMessage *content = (RCImageMessage *)currentMessage.content;
// Image URL obtained after uploading to your server
content.remoteUrl = @"https://www.test.com/img/test.jpg";
uploadListener.successBlock(content);
}
} progress:^(int progress, long messageId) {
//Media upload progress, requires manual UI refresh
} success:^(long messageId) {
} error:^(RCErrorCode errorCode, long messageId) {
} cancel:^(long messageId) {
}];
How to Send @ Messages
@ messages are not a predefined message type in RC's IM service (see server documentation Message Type Overview). You can implement the function of @ mentioning others by setting mentionedInfo data in messages.
You can set information about @ mentioned persons in the RCMentionedInfo field of the message's RCMessageContent. Whether SDK built-in message types or your custom message types, they all directly or indirectly inherit from the RCMessageContent class, thus all support setting @ mention information.
MentionedInfo parameters:
| Parameter | Type | Description |
|---|---|---|
| type | RCMentionedType | (Required) Specifies the type of MentionedInfo. RC_Mentioned_All indicates mentioning (@) everyone. RC_Mentioned_Users indicates @ mentioning specific people, who must be specified in userIdList. |
| userIdList | NSArray | Collection of user IDs to be mentioned (@). Required when type is RC_Mentioned_Users. Starting from version 5.3.1, supporting when type is RC_Mentioned_All while also mentioning specific people in userIdList. The receiving end can obtain userIdList data via RCMentionedInfo. |
| mentionedContent | NSString | Content displayed in the notification bar when triggering offline push notifications. If nil, the default prompt ("Someone @ mentioned you") is displayed. The mentionedContent carried by @ messages has the highest priority and will override all default or custom pushContent data. |
The following example demonstrates sending a text message mentioning specific users to a group chat session.
RCTextMessage *messageContent = [RCTextMessage messageWithContent:@"Test text message"];
// Set @ mention related information
messageContent.mentionedInfo = [[RCMentionedInfo alloc]
initWithMentionedType:RC_Mentioned_Users
userIdList:@[@"userId1", @"userId2"]
mentionedContent:nil];
RCMessage *message = [[RCMessage alloc]
initWithType:ConversationType_GROUP
targetId:@"targetId"
direction:MessageDirection_SEND
content:messageContent];
[[RCCoreClient sharedRCCoreClient]
sendMessage:message
pushContent:nil
pushData:nil
successBlock:^(RCMessage *successMessage) {
//Success
}
errorBlock:^(RCErrorCode nErrorCode, RCMessage *errorMessage) {
//Failure
}];
After the IMLib SDK receives the message, you need to process the @ message data. You can obtain the RCMentionedInfo object carried by the message object after getting the RCMessage (message object).
Remote Notifications
Chatroom sessions do not support offline message mechanisms, hence they also do not support offline message-to-push conversion.
If your application has configured third-party push with RC, when message recipients are offline, the RC server will determine whether to trigger remote push based on message type, recipient's supported push channels, recipient's Do Not Disturb settings, etc.
Remote push notifications are typically displayed in the system's notification bar. RC's built-in message types will by default show notification titles and contents in the notification bar. For default push notification contents of various message types, see User Content Message Formats.
Configuring Message Push Attributes
If you need personalized offline push notifications, you can modify or specify the notification title, content, and other attributes of remote push through the following methods:
- Control push notification content by setting the
pushContentparameter in the input parameters of sendMessage and sendMediaMessage methods. - If you need to control more attributes of offline push notifications, such as title, content, icon, or make personalized configurations according to third-party vendor channels, use the push attributes (RCMessagePushConfig) of RCMessage for configuration.
Compared to the pushContent and pushData in the input parameters when sending messages, configurations in MessagePushConfig have higher priority. When sending messages, if you have configured the messagePushConfig property of RCMessage, the configurations in messagePushConfig will be used first.
You can personalize the push behavior of individual messages by setting the messagePushConfig property of RCMessage. For example:
- Customize push title and notification content
- Customize notification bar icons
- Add remote push additional information
- Bypass recipient client configurations to forcibly display notification content in push notifications
- Other personalized configurations supported by APNs, HarmonyOS, or Android push channels
RCTextMessage *txtMsg = [RCTextMessage messageWithContent:@"Test text message"];
RCMessage *message = [[RCMessage alloc]
initWithType:ConversationType_PRIVATE
targetId:@"targetId"
direction:MessageDirection_SEND
content:txtMsg];
RCMessagePushConfig *pushConfig = [[RCMessagePushConfig alloc] init];
pushConfig.disablePushTitle = NO;
pushConfig.pushTitle = @"Notification Title";
pushConfig.pushContent = @"Notification Content";
pushConfig.pushData = @"Notification's pushData";
pushConfig.templateId = @"templateId";
pushConfig.iosConfig.threadId = @"iOS notification grouping ID";
pushConfig.iosConfig.apnsCollapseId = @"iOS notification override ID";
pushConfig.iosConfig.richMediaUri = @"iOS push custom notification bar message right icon URL";
pushConfig.androidConfig.notificationId = @"Android notification ID";
pushConfig.androidConfig.channelIdMi = @"Xiaomi's channelId";
pushConfig.androidConfig.channelIdHW = @"Huawei's channelId";
pushConfig.androidConfig.categoryHW = @"Huawei's Category";
pushConfig.androidConfig.channelIdOPPO = @"OPPO's channelId";
pushConfig.androidConfig.typeVivo = @"vivo's classification";
pushConfig.androidConfig.categoryVivo = @"vivo's Category";
pushConfig.hmosConfig.imageUrl = "HarmonyOS notification bar message right large icon URL";
pushConfig.hmosConfig.category = "HarmonyOS push message classification";
pushConfig.forceShowDetailContent = YES;
message.messagePushConfig = pushConfig;
Message push attribute descriptions (RCMessagePushConfig) provide the following parameters:
| Parameter | Type | Description |
|---|---|---|
| disablePushTitle | BOOL | Whether to block notification titles. This property only takes effect when the target user is on iOS platform. Android third-party push platforms require notification titles as mandatory fields, so this is not currently supported. |
| pushTitle | NSString | Push title. The push title specified here has the highest priority. If not set, refer to User Content Message Formats for default push notification titles and push notification contents of built-in message types. |
| pushContent | NSString | Push content. The push content specified here has the highest priority. If not set, refer to User Content Message Formats for default push notification titles and push notification contents of built-in message types. |
| pushData | NSString | Remote push additional information. If none, the pushData of the sent message is used. |
| forceShowDetailContent | BOOL | Whether to forcibly display notification details. When target users set push not to display message details via RCPushProfile's - (void)updateShowPushContentStatus:(BOOL)isShowPushContent success:(void (^)(void))successBlock error:(void (^)(RCErrorCode status))errorBlock;, this parameter can forcibly set this message to display push details. |
| templateId | NSString | Push template ID. After setting, match the language content set in the template according to the language environment set by the target user via SDK RCPushProfile's setPushLauguageCode for push. If no match is successful, default content is used for push. Template content is set in the console's Custom Push Copywriting. |
| iOSConfig | RCiOSConfig | iOS platform related configurations. See RCiOSConfig Attribute Descriptions. |
| androidConfig | RCAndroidConfig | Android platform related configurations. RCiOSConfig Attribute Descriptions. |
| hmosConfig | RCHarmonyOSConfig | HarmonyOS platform related configurations. RCHarmonyOSConfig Attribute Descriptions. |
-
RCiOSConfig Attribute Descriptions
Parameter Type Description threadId NSString iOS notification grouping ID. Notifications with the same threadId will be grouped together (supported since iOS 10) apnsCollapseId NSString iOS notification replacement ID. When apnsCollapseId is the same, new notifications will replace old ones (max 64 bytes, supported since iOS 10) richMediaUri NSString Custom notification icon URL for iOS push notifications (right side). Apps need to parse richMediaUriand implement the display. Image requirements: 120 * 120px, PNG or JPG format. Supported since SDK version 5.2.4.interruptionLevel NSString Applies to iOS 15 and later systems. Values: passive,active(default),time-sensitive, orcritical. For details, refer to APNs interruption-level. In iOS 15+, system features like "Scheduled Summary" and "Focus Mode" may prevent important notifications (e.g., balance changes) from being noticed promptly. Consider setting this field. Supported since SDK version 5.6.7. -
RCAndroidConfig Attribute Descriptions
Parameter Type Description notificationId NSString Unique identifier for Android push notifications. Currently supports Xiaomi and Huawei push platforms. By default, developers don't need to set this - the message's messageUId will be used as notificationId when generating push notifications. channelIdMi NSString Xiaomi channel ID for push notifications targeting Xiaomi devices. If Xiaomi push is integrated and channelIdneeds to be specified, consult Android developers. Channel IDs are created by developers.miLargeIconUrl NSString (This feature is no longer supported by Xiaomi) URL for the notification image used in Xiaomi push notifications. Image requirements: 120 * 120px, PNG or JPG format.
Supported since version 5.1.7. Works with MIUI China (requires MIUI 12+) and global versions.channelIdHW NSString Huawei channel ID for push notifications targeting Huawei devices. If Huawei push is integrated and channelIdneeds to be specified, consult Android developers. Channel IDs are created by developers.hwImageUrl NSString URL for the custom small notification icon (right side) in Huawei push notifications. If not set, no icon will be shown. File size must be <512 KB. Recommended size: 40dp x 40dp with 8dp rounded corners. Icons exceeding recommended size may be compressed or incompletely displayed.
Supported since version 5.1.7.categoryHW NSString Huawei push message self-classification identifier. Default is empty. Must be uppercase letters (e.g., IM). Becomes valid after completing [Huawei Self-Classification Application] or Special Permission Application. See Huawei's official Huawei Message Classification Standards. This field takes precedence over the Huawei push Category configured in Console for the App Key. Supported since SDK version 5.4.0.importanceHW RCImportanceHw Huawei push notification priority level. RCImportanceHwLowmeans silent notification (no sound/vibration).RCImportanceHwNormalmeans strong notification (with sound/vibration). Actual notification behavior depends oncategoryHWvalue, Console-configuredcategory, or Huawei Smart Classification results. Supported since SDK version 5.1.3.imageUrlHonor NSString URL for the custom large notification icon (right side) in Honor push notifications. If not set, no icon will be shown. File size must be <512 KB. Recommended size: 40dp x 40dp with 8dp rounded corners. Icons exceeding recommended size may be compressed or incompletely displayed. Supported since SDK version 5.6.7. importanceHonor RCimportanceHonor Honor push notification classification for Android, determining user device notification behavior. RCImportanceHonorLowfor marketing messages.RCImportanceHonorNormal(default) for service/communication messages. Supported since SDK version 5.6.7.typeVivo NSString VIVO push service message type. Options: 0(marketing messages) and1(system messages). Corresponds to VIVO'sclassificationfield. See [VIVO Push Message Classification].categoryVivo NSString VIVO push service message subcategory (e.g., IMfor instant messages). Corresponds to VIVO'scategoryfield. For valid values, see [VIVO Push Message Classification]. If specifyingcategoryVivo, must also specifytypeVivo. Ensure content complies with VIVO's requirements. Takes precedence over VIVO push Category configured in Console for the App Key. Supported since SDK version 5.4.2.channelIdOPPO NSString OPPO channel ID for push notifications targeting OPPO devices. If OPPO push is integrated and channelIdneeds to be specified, consult Android developers. Channel IDs are created by developers.fcmCollapseKey NSString FCM push notification group ID. Supported since SDK version 5.1.3. Note: When using this field, ensure FCM push configuration in Console uses Notification Message mode. fcmImageUrl NSString URL for FCM push notification icon (right side). If not set, no icon will be shown. Supported since SDK version 5.1.3. Note: When using this field, ensure FCM push configuration in Console uses Certificate authentication and Notification Message mode. fcmChannelId NSString FCM channel ID for push notifications. If FCM push is integrated and channelIdneeds to be specified, consult Android developers. Channel IDs are created by developers.Channel IDs need to be created by Android developers as follows:
Push Platform Configuration Instructions Huawei Create Channel ID by calling Android SDK API on app side Xiaomi Create Channel ID on Xiaomi Developer Platform or via Xiaomi server API OPPO Create Channel ID by calling Android SDK on app side; register the same Channel ID on OPPO Developer Platform vivo Create Channel ID via server API - RCHarmonyOSConfig Attribute Descriptions
| Parameter | Type | Description |
|---|---|---|
| imageUrl | NSString | HarmonyOS notification bar message large icon URL (right side). Supported formats: png, jpg, jpeg, heif, gif, bmp. Image dimensions (length*width) must be <25,000 pixels. If requirements aren't met, the notification message won't display. |
| category | NSString | HarmonyOS push message category (default empty). Values must be uppercase letters. See HarmonyOS category documentation for details. |
How to Enable Remote Push Notifications for Custom Messages
IMLib SDK implements remote notification titles and content for built-in message types (see User Content Message Formats). If you're sending custom message types, you must provide the pushContent field yourself; otherwise, recipients won't receive offline push notifications. Details:
- For custom message types requiring offline push support, you must provide the
pushContentfield either through message parameters or push attributes. Otherwise, users won't receive offline push notifications. - For custom message types not requiring remote push (e.g., app-level operation commands implemented via custom messages), leave
pushContentempty.
Disabling Push Notifications for Messages
When recipients are offline, RC server triggers push services by default to deliver messages through push channels (server-side push triggering is also affected by application-level and user-level Do Not Disturb settings).
Sometimes app users may want to specify that certain messages shouldn't trigger pushes. This can be achieved via the MessageConfig configuration in the RCMessage object.
In the following example, we set disableNotification to YES in messageConfig to disable push notifications for this message. When recipients come back online, they'll automatically receive one-to-one, group, and system conversation messages through RC's offline message cache (retained for up to 7 days). Ultra group messages aren't supported by offline mechanisms and require active retrieval.
RCTextMessage *messageContent = [RCTextMessage messageWithContent:@"Test text message"];
RCMessage *message = [[RCMessage alloc]
initWithType:ConversationType_PRIVATE
targetId:@"targetId"
direction:MessageDirection_SEND
content:MessageContent];
message.messageConfig.disableNotification = YES;
How to Transmit Custom Data
To send custom data to recipients:
- Use the
extrafield in RCMessageContent - this field is sent with real-time messages. Online recipients can retrieve it from message content. Note: This differs fromRCMessage'sextrafield, which is local-only and not sent to the server. - Use remote push attachment
pushData. You can setpushDatadirectly in sendMessage and sendMediaMessage parameters, or use the identically named field in message push attributes (the latter overrides the former).
pushData is only delivered to recipient devices when offline push is triggered. Recipients can access transmitted data through the appData field in push notifications. See [Get Push Data] in Integrate APNs Remote Push.
Handling Message Send Failures
- For message types stored locally by the client (see Message Type Overview), if the
errorBlockcallback is triggered, the app can temporarily display the failed message in UI, cache theRCMessageinstance fromerrorBlock, and resend by callingsendMessageorsendMediaMessagelater. - For messages not stored locally, if sending fails (
errorBlock), the app can either cache and retry with the same instance or create a new instance.
For locally stored message types, if you resend without reusing the errorBlock's RCMessage instance (i.e., create a new message with identical content), the local message list will contain duplicate entries.
Implementing Message Forwarding and Bulk Sending
Forwarding Messages: IMLib SDK doesn't provide a dedicated forwarding interface. To implement forwarding, call the standard message sending API.
Bulk Sending: This refers to sending messages to multiple users (more accurately, to multiple Target IDs?, where each ID may represent a user, group, or chatroom). The client SDK doesn't directly support bulk sending. Consider these approaches:
- Have the app loop through client sending APIs (note: client SDK limits sending to 5 messages/second).
- Integrate IM Server API on your business server for bulk sending. The Send Private Message interface supports sending to multiple users simultaneously. You can also use Send Group Message or Send Chatroom Message to target multiple groups/chatrooms at once.