LinuxIntegration.Notifications
1.0.0
إخطارات سطح المكتب Linux الأصلي
عملية بناء dotnet القياسية ، dotnet build
يمكنك تثبيت هذه الحزمة من nuget https://www.nuget.org/packages/rbnswartz.linuxintegration.notifications/
قم بإنشاء مثيل من الإخطار و Call DistipificationAsync
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 ) ;احصل على المعرف الذي تم إرجاعه عند إنشاء الإشعار ثم اتصل بـ 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 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 ) ;