LinuxIntegration.Notifications
1.0.0
ネイティブLinuxデスクトップ通知
標準のdotnetビルドプロセス、 dotnet build
このパッケージは、nuget https://www.nuget.org/packages/rbnswartz.linuxintegration.notifications/からインストールできます。
NotificationManagerのインスタンスを作成し、shownotificationasyncを呼び出します
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を取得してから、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 ) ;通知システムがそれらをサポートする場合、カスタムアクションを通知に追加できます。
NotificationManagerのSupportSactionsプロパティを調べることでサポートされているかどうかを確認できます
アクションがサポートされている場合は、このように使用できます。辞書のキーは表示された値であり、値はアクションがクリックされたときに呼び出されるアクションです
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 ) ;