SDKsiOS
Set global message reception
Configure the signed-in account’s default message-reception and notification behavior with OpenIM iOS SDK.
Configure the account-wide default message reception policy and offline push notification behavior using setGlobalRecvMessageOpt:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
opt | OIMReceiveMessageOpt | Yes | Global message reception enum option. |
Message reception options
| Enum | Value | Description |
|---|---|---|
OIMReceiveMessageOptReceive | 0 | Receive messages normally and trigger offline push notifications. |
OIMReceiveMessageOptNotReceive | 1 | Block message reception entirely; suppress offline push notifications. |
OIMReceiveMessageOptNotNotify | 2 | Receive 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
userIDas 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
globalRecvMsgOptproperty.
Was this page helpful?