Нативные уведомления на рабочем столе Linux
Стандартный процесс сборки Dotnet, dotnet build
Вы можете установить этот пакет с Nuget https://www.nuget.org/packages/rbnswartz.linuxintegration.notifications/
Создайте экземпляр уведомления Manager и вызовы showtotificationAsync
NotificationManager manager = new NotificationManager ( "test app" ) ;
var summary = "This is a summary" ;
var body = "This is the body of the notification" ;
await manager . ShowNotificationAsync ( summary , body , expiration : 5000 ) ;Получите возвращенный идентификатор при создании уведомления, а затем вызовите HidenotificationAsync
NotificationManager manager = new NotificationManager ( "test app" ) ;
var summary = "This is a summary" ;
var body = "This is the body of the notification" ;
var id = await manager . ShowNotificationAsync ( summary , body , expiration : 5000 ) ;
await manager . HideNotificationAsync ( id ) ;Пользовательские действия могут быть добавлены в уведомление, если система уведомлений поддерживает их.
Вы можете проверить, поддерживается ли это, просмотрев свойство поддержки на уведомлении Manager
Если действия поддерживаются, вы можете использовать их так. Ключом словаря является отображаемое значение, а значение - это действие, которое будет вызвано при нажатии действия
NotificationManager manager = new NotificationManager ( "test app" ) ;
var summary = "This is a summary" ;
var body = "This is the body of the notification" ;
var notificationId = await manager . ShowNotificationAsync ( summary , body , actions : new Dictionary < string , Action > ( )
{
[ "Press me" ] = ( ) => Console . WriteLine ( "Press me action called" ) ,
[ "Do other important thing" ] = ( ) => Console . WriteLine ( "Other important thing" )
} ,
expiration : 5000 ) ;