IM 即时通讯
Windows/macOS
产品介绍
简介
主要功能
产品优势
海外数据中心
IM平滑迁移方案
接口及业务限制
功能介绍
帐号集成与登录
基础消息功能
群组功能
聊天室功能
聊天室标签功能
圈组功能
多端登录与互踢策略
质量数据监控台
更新日志
Demo 更新日志
NIM SDK 更新日志
快速开始
实现单聊消息收发(不含 UI)
实现圈组消息收发(不含 UI)
开发指南
概要介绍
集成方式(当前版本)
集成方式(Windows旧版本)
集成方式(macOS旧版本)
初始化
登录登出
消息收发
最近会话
历史记录
用户资料托管
好友关系托管
事件订阅
系统通知
系统通知概述
内置系统通知管理
内置系统通知未读数
自定义系统通知收发
群组功能
群组概述
群组管理
群成员管理
群消息管理
超大群功能
开通聊天室功能
聊天室
圈组功能
初始化
登录圈组
圈组服务器管理
圈组服务器成员管理
游客功能
频道相关
频道管理
频道分组
频道分组黑白名单
频道未读数管理
搜索服务器和频道
身份组相关
身份组概述
身份组应用场景
服务器身份组
频道身份组
频道分组身份组
频道用户定制权限
自定义权限项
成员权限判定
身份组相关查询
圈组订阅机制
圈组消息相关
圈组消息收发
圈组消息撤回
圈组消息更新
圈组消息删除
会话消息回复(Thread)
圈组快捷评论
获取频道最后一条消息
消息正在输入
圈组消息搜索
圈组消息查询
查询@我的消息
服务器未读数
圈组系统通知
圈组系统通知概述
圈组系统通知收发
圈组系统通知更新
圈组各端接口命名差异
语音录制与播放
NOS云存储服务
文档转换
API 参考
Windows/macOS API 参考
状态码
IM 控制台指南
创建应用
注册 IM 账号
升级服务
配置应用客户端标识
参考文档
升级指引
开发示例
UI库指南
Demo源码导读
打包发布
类与常量定义说明
常见问题
FAQ
服务协议

系统通知

更新时间: 2022/06/16 14:08:07

圈组系统通知概览

系统通知可分为内置系统通知和自定义系统通知。

系统通知类型 说明 离线系统通知限制
内置系统通知 圈组内置的系统通知, 类型包括“邀请服务器成员”、“踢除服务器成员”、“修改频道信息” 等 服务器成员管理事件的系统通知支持存离线,每月至多存 1,000 条离线通知。其他内置系统通知不存离线
自定义系统通知 开发者自定义系统通知。 SDK 不解析自定义系统通知,仅负责传递 每月 1,000 条离线通知

内置系统通知分类

圈组内置系统通知,可进一步分为服务器成员管理事件的系统通知服务器其他相关事件的系统通知频道事件系统通知频道分组事件系统通知身份组成员管理事件的系统通知身份组权限事件系统通知。除了服务器成员管理事件的系统通知,其余类型都通过参与者与观察者机制控制接收人及其接收条件。

每个类型的具体触发条件和接收条件,请参考服务端的圈组系统通知

技术原理

圈组中的系统通知时由云信服务器下发给用户的通知类消息,用于包括创建 Server、创建 Channel、申请加入 Server 等事件的通知。

SDK 中的 QChatSystemNotification 结构定义圈组的系统通知。

其中,QChatSystemNotification 中的系统通知类型,具体可参考 NIMQChatSystemNotificationType

实现方法

发送系统通知

可通过 send 方法发送系统消息。 其中,QChatSendSystemNotificationParam是发送系统通知的入参。

示例代码

QChatSendSystemNotificationParam param;
param.notification.server_id = 123456;
param.notification.channel_id = 123456;
param.notification.msg_type = kNIMQChatSystemNotificationTypeCustom;
param.notification.msg_body = "msg body";
param.notification.msg_attach = "msg attach";
param.notification.msg_ext = "msg ext";
param.notification.resend_flag = false;
param.notification.msg_id = ""; // only for resend. if not, leave it empty, we will generate it
param.notification.to_accids = {"accid1", "accid2"};
param.notification.history_enable = false;
param.notification.push_payload = "push payload";
param.notification.push_content = "push content";
param.notification.push_enable = false;
param.notification.need_badge = true;
param.notification.need_push_nick = true;
param.cb = [this](const QChatSendSystemNotificationResp& resp) {
    if (resp.res_code != NIMResCode::kNIMResSuccess) {
        // error handling
        return;
    }
    // process response
    // ...
};
SystemNotification::Send(param);

更新系统通知

可通过 Update 方法更新系统通知。 其中,QChatUpdateSystemNotificationParam 是更新系统通知的入参。

示例代码

QChatUpdateSystemNotificationParam param;
param.msg_server_id = 123456;
param.msg_type = kNIMQChatSystemNotificationTypeCustom;
param.status = kNIMQChatSystemNotificationNormal;
param.msg_body = "msg body";
param.msg_ext = "msg ext";
param.update_info.postscript = "postscript";
param.update_info.extension = "extension";
param.update_info.push_content = "push content";
param.update_info.push_payload = "push payload";
param.cb = [this](const QChatUpdateSystemNotificationResp& resp) {
    if (resp.res_code != NIMResCode::kNIMResSuccess) {
        // error handling
        return;
    }
    // process response
    // ...
};
SystemNotification::Update(param);

标记系统通知已读

可通过 MarkSystemNotificationsRead 方法标记系统通知已读。 其中,QChatMarkSystemNotificationsReadParam 是标记系统通知已读的入参。

QChatMarkSystemNotificationsReadParam param;
NIMQChatSystemNotificationMarkReadInfo info;
info.msg_server_id = 123456;
info.msg_type = kNIMQChatSystemNotificationTypeCustom;
param.mark_read_infos.emplace_back(info);
param.cb = [this](const QChatMarkReadSystemNotificationResp& resp) {
    if (resp.res_code != NIMResCode::kNIMResSuccess) {
        // error handling
        return;
    }
    // process response
    // ...
};
SystemNotification::MarkSystemNotificationsRead(param);

接收系统通知回调

可通过 RegRecvCb 方法注册接收系统通知回调,当发生能触发系统通知的事件后,用户会接收到系统通知回调。 其中,QChatRegRecvSystemNotificationCbParam 是注册接收系统通知回调的入参。

示例代码

QChatRegRecvSystemNotificationCbParam reg_receive_sysmessage_cb_param;
reg_receive_sysmessage_cb_param.cb = [this](const QChatRecvSystemNotificationResp& resp) {
    if (resp.res_code != NIMResCode::kNIMResSuccess) {
        // error handling
        return;
    }
    // process response
    // ...
};
SystemNotification::RegRecvCb(reg_receive_sysmessage_cb_param);

系统通知变更回调

可通过 RegUpdatedCb 方法注册接收系统通知回调,当发生能触发系统通知变更的事件后,用户会接收到系统通知变更回调。 其中,QChatRegSystemNotificationUpdatedCbParam 是注册系统通知变更回调的入参。

示例代码

QChatRegSystemNotificationUpdatedCbParam reg_notification_updated_cb_param;
reg_notification_updated_cb_param.cb = [this](const QChatSystemNotificationUpdatedResp& resp) {
    if (resp.res_code != NIMResCode::kNIMResSuccess) {
        // error handling
        return;
    }
    // process response
    // ...
};
SystemNotification::RegUpdatedCb(reg_notification_updated_cb_param);
此文档是否对你有帮助?
有帮助
我要吐槽
  • 圈组系统通知概览
  • 内置系统通知分类
  • 技术原理
  • 实现方法
  • 发送系统通知
  • 示例代码
  • 更新系统通知
  • 示例代码
  • 标记系统通知已读
  • 接收系统通知回调
  • 示例代码
  • 系统通知变更回调
  • 示例代码