SDKsiOS
设置全局消息接收方式
使用 iOS SDK 设置当前账号的默认消息接收与通知方式。
设置当前账号默认的消息接收和离线推送通知策略:
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
opt | OIMReceiveMessageOpt | 消息接收选项枚举值。 |
| 枚举值 | 数值 | 含义 |
|---|---|---|
OIMReceiveMessageOptReceive | 0 | 正常接收消息,并允许离线推送或通知。 |
OIMReceiveMessageOptNotReceive | 1 | 不接收消息,也不触发离线推送或通知。 |
OIMReceiveMessageOptNotNotify | 2 | 接收消息,但不触发离线推送或通知。 |
[[OIMManager manager] setGlobalRecvMessageOpt:OIMReceiveMessageOptNotNotify
onSuccess:^(NSString *data) {
[profileStore refreshGlobalRecvOpt:OIMReceiveMessageOptNotNotify];
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"setGlobalRecvMessageOpt failed: %ld %@", (long)code, message);
}];如果产品只提供“全局免打扰”开关,通常在 Receive 与 NotNotify 之间切换;NotReceive 会直接拒绝拉取消息,应作为独立选项谨慎展示。
返回结果
成功回调 onSuccess 表示服务端已更新该全局设置。状态以当前账号 userID 为合并标识。需要确认最终生效值时,可通过获取当前用户资料重新查询校准。
这个页面有帮助吗?