LinuxIntegration.Notifications
1.0.0
การแจ้งเตือนเดสก์ท็อป Linux ดั้งเดิม
กระบวนการสร้าง Dotnet Standard, dotnet build
คุณสามารถติดตั้งแพ็คเกจนี้ได้จาก Nuget https://www.nuget.org/packages/rbnswartz.linuxintegration.notifications/
สร้างอินสแตนซ์ของ NotificationManager และการโทรที่แสดง
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 ) ;รับ ID ที่ส่งคืนเมื่อคุณสร้างการแจ้งเตือนแล้วโทรหา HidenotificationAsnc
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 ) ;การกระทำที่กำหนดเองสามารถเพิ่มลงในการแจ้งเตือนหากระบบการแจ้งเตือนสนับสนุนพวกเขา
คุณสามารถตรวจสอบว่าได้รับการสนับสนุนหรือไม่โดยดูที่คุณสมบัติการสนับสนุนใน NotificationManager
หากการสนับสนุนได้รับการสนับสนุนคุณสามารถใช้เช่นนี้ได้ กุญแจสำคัญของพจนานุกรมคือค่าที่แสดงและค่าคือการกระทำที่จะถูกเรียกเมื่อคลิกการกระทำ
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 ) ;