LinuxIntegration.Notifications
1.0.0
本机Linux桌面通知
标准dotnet构建过程, dotnet build
您可以从Nuget https://www.nuget.org/packages/rbnswartz.linuxintegration.notification/
创建一个通知manager的实例,并调用Adswotification Async
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,然后致电HidenotificationAsyAsync
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上的suptortations属性来检查它是否得到支持
如果支持动作,则可以这样使用它们。字典的键是显示的值,该值是单击操作时将调用的操作
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 ) ;