Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

Notification not working

$
0
0

I have a Xam.Mac Cocoa application, created using Visual Studio.app. I have a ClickedButton method wired up to a button, and I'm able to do things like create modal alert dialogues, save a string to pasteboard, and manipulate some textfield.StringValue. For some reason, I can't get a notification to pop up. Not sure why this isn't working:

var notification = new NSUserNotification();

// Add text and sound to the notification
notification.Title = "25 Minutes is up!";
notification.InformativeText = "Add your task to your activity log";
notification.SoundName = NSUserNotification.NSUserNotificationDefaultSoundName;
notification.HasActionButton = true;
NSUserNotificationCenter.DefaultUserNotificationCenter.DeliverNotification(notification);

or

var myNotification = new NSUserNotification();

myNotification.Title = "Hello World";
myNotification.InformativeText = "This is an informative text";
myNotification.DeliveryDate = (NSDate)DateTime.Now;
myNotification.SoundName = NSUserNotification.NSUserNotificationDefaultSoundName;
NSUserNotificationCenter.DefaultUserNotificationCenter.DeliverNotification(myNotification);

By setting a breakpoint, I can see my code reached a line after this stuff, so it's not like my thread is hanging on some other call before getting here. Simply, nothing happens.

Except once. Mysteriously, one time, I got a notification to pop up, but have never been able to repeat that.

Visual Studio Community 7.2.2 (build 11)
Mono 5.4.1.6
Xamarin.Mac 3.8.1.0
macOS 10.13.1 High Sierra

Thanks for any suggestions...


Viewing all articles
Browse latest Browse all 1429

Trending Articles