NIM PC Cross Platform SDK
载入中...
搜索中...
未找到
v2::V2NIMNotificationService类 参考abstract

通知服务 更多...

#include <v2_nim_notification_service.hpp>

Public 成员函数

virtual void sendCustomNotification (nstd::string conversationId, nstd::string content, V2NIMSendCustomNotificationParams params, V2NIMSuccessCallback< void > success, V2NIMFailureCallback failure)=0
 发送自定义通知
 
virtual void addNotificationListener (V2NIMNotificationListener listener)=0
 添加通知监听器
 
virtual void removeNotificationListener (V2NIMNotificationListener listener)=0
 移除通知监听器
 

详细描述

通知服务

前置条件
调用 V2NIMClient::get() 拿到 client 实例 调用 client.getNotificationService() 拿到 notificationService 实例
示例代码
auto& client = V2NIMClient::get();
auto& notificationService = client.getNotificationService();
static V2NIMClient & get()
获取 IM 客户端实例
Definition: v2_nim_api.hpp:428

成员函数说明

◆ addNotificationListener()

virtual void v2::V2NIMNotificationService::addNotificationListener ( V2NIMNotificationListener  listener)
pure virtual

添加通知监听器

参数
listener通知监听器
返回
void
示例代码
// handle custom notifications
};
// handle broadcast notifications
};
notificationService.addNotificationListener(listener);
Definition: ne_stl_continuous_container.h:15
Definition: v2_nim_def_callback.hpp:134
nstd::function< void(nstd::vector< V2NIMCustomNotification > customNotification)> onReceiveCustomNotifications
收到自定义
Definition: v2_nim_def_callback.hpp:136
nstd::function< void(nstd::vector< V2NIMBroadcastNotification > broadcastNotification)> onReceiveBroadcastNotifications
收到广播
Definition: v2_nim_def_callback.hpp:138

◆ removeNotificationListener()

virtual void v2::V2NIMNotificationService::removeNotificationListener ( V2NIMNotificationListener  listener)
pure virtual

移除通知监听器

参数
listener通知监听器
返回
void
示例代码
// ...
conversationService.addNotificationListener(listener);
// ...
conversationService.removeNotificationListener(listener);

◆ sendCustomNotification()

virtual void v2::V2NIMNotificationService::sendCustomNotification ( nstd::string  conversationId,
nstd::string  content,
V2NIMSendCustomNotificationParams  params,
V2NIMSuccessCallback< void >  success,
V2NIMFailureCallback  failure 
)
pure virtual

发送自定义通知

参数
conversationId会话 ID
content通知内容
params发送通知相关配置参数
success成功回调
failure失败回调
返回
void
示例代码
auto conversationId = V2NIMConversationIdUtil::p2pConversationId("target_account_id");
notificationService.sendCustomNotification(
conversationId,
"hello world",
params,
[]() {
// send notification succeeded
},
[](V2NIMError error) {
// send notification failed
});
Definition: v2_nim_def_struct.hpp:7
Definition: v2_nim_def_struct.hpp:888
static nstd::string p2pConversationId(const nstd::string &accountId)
获取点对点会话ID
Definition: v2_nim_internal.hpp:246

该类的文档由以下文件生成: