Browse SDKs · iOS
Platform
SDKsiOS

Set global message reception

Configure the signed-in account’s default message-reception and notification behavior with OpenIM iOS SDK.

Copy

Configure the account-wide default message reception policy and offline push notification behavior using setGlobalRecvMessageOpt:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
optOIMReceiveMessageOptYesGlobal message reception enum option.

Message reception options

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

If your application provides a single "Do Not Disturb" toggle, switch between Receive and NotNotify. Present NotReceive with caution, as it completely stops new message delivery to the client.

Code example

[[OIMManager manager] setGlobalRecvMessageOpt:OIMReceiveMessageOptNotNotify
                                    onSuccess:^(NSString *data) {
    [profileStore refreshGlobalRecvOpt:OIMReceiveMessageOptNotNotify];
}
                                    onFailure:^(NSInteger code, NSString *message) {
    NSLog(@"setGlobalRecvMessageOpt failed: %ld %@", (long)code, message);
}];

Return value

The onSuccess callback signifies that OpenIMServer updated the global reception preference.

State changes after the call

  • Local state merge: Merge setting state using the authenticated user's userID as the unique entity key.
  • Verification and calibration: When authoritative confirmation is needed, invoke Retrieve your profile to re-query the current user's profile and inspect the updated globalRecvMsgOpt property.