我正在处理Xamarin通知。我可以使用操作按钮发送通知, 我想单击操作按钮来执行某些功能。
代码为波纹管。
var builder = new NotificationCompat.Builder(this)
.SetContentIntent(contentIntent)
// .SetContentTitle("Sample Notification")
//.SetContentText("Hello World! This is my first notification!")
.SetContentTitle(title)
.SetContentText(notiBody)
// AddAction(Int32 icon, String title, PendingIntent intent)
.AddAction(Resource.Drawable.postComment, "Approve", contentIntent)
.AddAction(Resource.Drawable.deleteIcon, "Reject", contentIntent)
.SetSmallIcon(Resource.Drawable.logoCS)
.SetPriority((int)NotificationPriority.Max)
.SetAutoCancel(true);
// Build the notification:
Notification notification = builder.Build();
// Get the notification manager:
NotificationManager notificationManager =
GetSystemService(Context.NotificationService) as NotificationManager;
// Publish the notification:
const int notificationId = 0;
notificationManager.Notify(notificationId, notification);