LinuxIntegration.Notifications
1.0.0
Pemberitahuan Desktop Linux Asli
Proses pembuatan dotnet standar, dotnet build
Anda dapat menginstal paket ini dari nuget https://www.nuget.org/packages/rbnswartz.linuxintegration.notifications/
Buat instance notificationManager dan call showootificationAnnc
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 ) ;Dapatkan ID yang dikembalikan saat Anda membuat pemberitahuan dan kemudian hubungi 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 ) ;Tindakan khusus dapat ditambahkan ke pemberitahuan jika sistem pemberitahuan mendukungnya.
Anda dapat memeriksa apakah itu didukung dengan melihat properti SupportSactions di notificationManager
Jika tindakan didukung, Anda dapat menggunakannya seperti ini. Kunci kamus adalah nilai yang ditampilkan dan nilainya adalah tindakan yang akan dipanggil saat tindakan diklik
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 ) ;