LinuxIntegration.Notifications
1.0.0
Notificações de desktop linux nativas
Processo de compilação do DOTNET padrão, dotnet build
Você pode instalar este pacote em nuget https://www.nuget.org/packages/rbnsswartz.linuxintegration.notifications/
Crie uma instância do NotificationManager e Call MostroutificationAsync
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 ) ;Obtenha o ID devolvido ao criar a notificação e depois ligue para 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 ) ;Ações personalizadas podem ser adicionadas a uma notificação se o sistema de notificação os suportar.
Você pode verificar se é suportado olhando a propriedade SupportSactions no NotificationManager
Se as ações forem suportadas, você poderá usá -las assim. A chave do dicionário é o valor exibido e o valor é uma ação que será chamada quando a ação for clicada
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 ) ;