pr8x / DesktopNotifications

A cross-platform C# library for native desktop "toast" notifications.
MIT License
177 stars 29 forks source link

Avalonia: Missing notification manager #11

Closed milkywayfarer closed 2 years ago

milkywayfarer commented 2 years ago

Just added the code from Avalonia example to my project. Targeted the new SDK. Everything builds fine except the line: public static INotificationManager notificationManager = AvaloniaLocator.Current.GetService<INotificationManager>() ?? throw new InvalidOperationException("Missing notification manager"); which throws.

pr8x commented 2 years ago

Do you call SetupDesktopNotifications during your app builder? https://github.com/pr8x/DesktopNotifications/blob/a7bccbe272010fd7a9ad995a8c1b04583a5acf2b/DesktopNotifications.Avalonia/AppBuilderExtensions.cs#L22

milkywayfarer commented 2 years ago

That did the job, thanks! For anyone wondering, add .SetupDesktopNotifications() to your AppBuilder.Configure<App>() in Program.cs file.