Unread System Notifications

Update time: 2023/03/23 09:27:00

The number of unread built-in system notifications indicates the total number of unread built-in system notifications received by users in the CommsEase system. This document describes how to get the unread count of built-in system notifications, mark the unread notifications read and provides corresponding sample code.

Prerequisites

The listener for system notifications is registered. For more information, see Listen to system notifications.

Query the number of built-in system notifications

C++

Query the number of built-in system notifications by calling the QueryUnreadCount method.

** Sample code:**

cppvoid OnQuerySysmsgUnreadCb(nim::NIMResCode res_code, int unread_count)
{
	if (res_code == 200)
		···
}

void foo()
{
	nim::SystemMsg::QueryUnreadCount(&OnQuerySysmsgUnreadCb);
}

Queries are made only in the local database.

:::

C

Query the number of built-in system notifications by calling the nim_sysmsg_query_unread_count method.

** Sample code:**

cvoid CallbackNotifySysmsgRes(int res_code, int unread_count, const char *json_extension, const void *callback)
{
	
}

typedef void(*nim_sysmsg_query_unread_count)(const char *json_extension, nim_sysmsg_res_cb_func cb, const void *user_data);
void foo()
{
	nim_sysmsg_query_unread_count func = (nim_sysmsg_query_unread_count) GetProcAddress(hInst, "nim_sysmsg_query_unread_count");
	func("", &CallbackNotifySysmsgRes, nullptr);
}

Mark all built-in system notifications read

C++

Mark all built-in system notifications read by calling the ReadAllAsync method. The unread count of the built-in system notifications is reset to 0.

** Sample code:**

cppvoid SysMsgReadAllCb(nim::NIMResCode code, int unread)
{

}
void foo()
{
	nim::SystemMsg::ReadAllAsync(&SysMsgReadAllCb);
}
C

Mark all built-in system notifications read by calling the nim_sysmsg_read_all_async method. The unread count of the built-in system notifications is reset to 0.

** Sample code:**

cvoid CallbackNotifySysmsgRes(int res_code, int unread_count, const char *json_extension, const void *callback)
{
	
}

typedef void(*nim_sysmsg_read_all_async)(const char *json_extension, nim_sysmsg_res_cb_func cb, const void* user_data);
void foo()
{
	nim_sysmsg_read_all_async func = (nim_sysmsg_read_all_async) GetProcAddress(hInst, "nim_sysmsg_read_all_async");
	func("", &CallbackNotifySysmsgRes, nullptr);
}

API reference

C++
API
Description
QueryUnreadCount Query the number of built-in system notifications.
ReadAllAsync Mark all built-in system notifications read and The unread count of the built-in system notifications is reset to 0.
C
API
Description
nim_sysmsg_query_unread_count Query the number of built-in system notifications.
nim_sysmsg_read_all_async Mark all built-in system notifications read and The unread count of the built-in system notifications is reset to 0.
Was this page helpful?
Yes
No
  • Prerequisites
  • Query the number of built-in system notifications
  • Mark all built-in system notifications read
  • API reference