【发布时间】:2020-08-14 21:05:33
【问题描述】:
如何通过单击本地通知以编程方式将 Xamarin MAC 应用程序置于前台?我怎样才能实现它?我为本地通知编写了以下代码。单击该本地通知时,我想将我的应用置于前台。
NSUserNotificationCenter center = NSUserNotificationCenter.DefaultUserNotificationCenter;
NSUserNotification notification = new NSUserNotification();
notification.Title = title;
notification.Subtitle = content;
notification.InformativeText = "TEST";
notification.SoundName = NSUserNotification.NSUserNotificationDefaultSoundName;
notification.DeliveryDate = NSDate.FromTimeIntervalSinceNow(1);
center.ScheduleNotification(notification);
center.DidDeliverNotification += (s, e) =>
{
Console.WriteLine("Notification Delivered");
};
center.DidActivateNotification += (s, e) =>
{
Console.WriteLine("Notification Touched");
};
提前谢谢你, 维韦克
【问题讨论】:
标签: macos xamarin xamarin.forms xamarin-studio xamarin.mac