Browse SDKs · iOS
Platform
SDKsiOS

Set message reception for a conversation

Configure message reception for a conversation with OpenIM iOS SDK.

Copy

Configure the message reception policy for a specific conversation (such as enabling Do Not Disturb or muting notifications) using setConversationRecvMessageOpt:status:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
statusOIMReceiveMessageOptYesMessage reception option enum.

Message reception options (OIMReceiveMessageOpt)

EnumValueDescription
OIMReceiveMessageOptReceive0Receive messages normally and trigger offline push notifications.
OIMReceiveMessageOptNotReceive1Block message reception entirely; suppress offline push notifications.
OIMReceiveMessageOptNotNotify2Receive messages while suppressing offline push notifications (Do Not Disturb).

Code example

[[OIMManager manager] setConversationRecvMessageOpt:@"c2c_user1002"
                                             status:OIMReceiveMessageOptNotNotify
                                          onSuccess:^(NSString * _Nullable data) {
                                              NSLog(@"setConversationRecvMessageOpt success");
                                          }
                                          onFailure:^(NSInteger code, NSString *message) {
                                              NSLog(@"setConversationRecvMessageOpt failed: %ld %@", (long)code, message);
                                          }];

Return value

The onSuccess callback confirms that OpenIMServer updated the message reception setting.

State changes after the call

  • Local state merge: Merge the updated recvMsgOpt property into local conversation models using conversationID as the entity key.
  • Asynchronous event listening: Multi-device clients observe changes via onConversationChanged: in OIMConversationListener (see Retrieve the conversation list).
  • Re-query calibration: To verify the active conversation configuration, invoke Retrieve conversations by ID.