WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Feature Request: Schedule toast notifications

Open whiskhub opened this issue 11 months ago • 7 comments

The ToastContentBuilder of the previous Microsoft.Toolkit.Uwp.Notifications API had the ability to schedule toast notifications for a date/time using ToastContentBuilder.Schedule.

The AppNotificationBuilder and AppNotificationManager APIs of Windows App SDK do not offer such an Scheduling API yet. This gap should be closed.

Also see discussions https://github.com/microsoft/WindowsAppSDK/discussions/5046, https://github.com/microsoft/WindowsAppSDK/discussions/3853.

whiskhub avatar Jan 18 '25 14:01 whiskhub

Please also implement all the accompanying functionality that UWP offers, for example the removing of a notification that has already been passed to Windows, e.g in UWP.:

var notifier = ToastNotificationManagerCompat.CreateToastNotifier();
var scheduled = notifier.GetScheduledToastNotifications();
foreach (var notification in scheduled)
      notifier.RemoveFromSchedule(notification);

Without this functionality, even scheduled notifications make absolutely no sense, because if the user changes his appointment, you must first delete it from Windows and only then set a new one.

It is best to migrate everything to winappSDK that UWP also offers, then you really can't do anything wrong.

Because UWP.Notifications Nuget has been around since 2016-2022. in these 6 years we will probably have understood what we need and what we don't need from the notification functionality. To decide independently in WinAppSDK which notification functionalities are taken over by UWP.Notifications and which are not (like sceduling here) really makes absolutely no sense and only makes the acceptance of MAUI more difficult.

pc

EDIT

If someone needs scheduled notifications for MAUI, then you have to use UWP.Notifications Nuget (as of January 2025) and there is a workaround from @whiskhub to get the ID sent by Windows. However, we all hope that the WinAppSDK team will implement a complete migration from UWP.Notification to windowsAppSDK so that WinAppSDK can be used for local notification in MAUI (as is also planned by Microsoft)

You can find a working example here: https://github.com/true-perfect-code/MauiApp1_UWPNotifications

pc

true-perfect-code avatar Jan 19 '25 10:01 true-perfect-code

I need the same feature, migrating from UWP to WinUI3

tipa avatar Jun 13 '25 16:06 tipa

I need the same feature, migrating from UWP to WinUI3

In WinUI 3, you can use Schedule a toast notification

castorix avatar Jun 13 '25 16:06 castorix

@castorix I don't think it is designed for MAUI, and the last update was on 01.11.2022! However, I have described the correct procedure in previous posts, i.e. complete migration to SDK!

true-perfect-code avatar Jun 13 '25 17:06 true-perfect-code

@castorix this looks like it's a documentation for UWP. It lists "A Windows 10 UWP app project" under Prerequisites and requires a UWP NuGet: "Microsoft.Toolkit.Uwp.Notifications".

There's also CommunityToolkit.WinUI.Notifications but it's deprecated and recommends Microsoft.WindowsAppSDK as alternative.

EDIT: nevermind, I think it's still possible using the UWP classes Windows.UI.Notifications.ScheduledToastNotification and Windows.UI.Notifications.ToastNotificationManager

tipa avatar Jun 13 '25 17:06 tipa

@castorix this looks like it's a documentation for UWP. It lists "A Windows 10 UWP app project" under Prerequisites and requires a UWP NuGet: "Microsoft.Toolkit.Uwp.Notifications".

Yes, but I had tested in WinUI 3/Unpakaged on Windows 10 and it seemed to work correctly (with ToastNotificationManagerCompat)

castorix avatar Jun 13 '25 18:06 castorix

@tipa
I have written about this in a lot of detail because I have dealt with it intensively. You can do it this way with Microsoft.Toolkit.Uwp.Notifications, but the problem is that you can't get any parameters sent by Windows because they have to be queried under Event Activated (if use Uwp.Notifications) and in MAUI we now have OnLaunched instead of OnActivated and the parameter from Windows doesn't arrive here.

So if you want to do it right, then the colleagues should add the most important function to the already migrated SDK notification and that would not be immediate display of the notification (as it is now with Show) but time-controlled with Scedule() as it is with Uwp.Notifications.

What really surprises me is that nobody from the MAUI community is talking about this problem, as if nobody uses MAUI to develop for Windows!

pc

true-perfect-code avatar Jun 13 '25 18:06 true-perfect-code

I just wanted to share a workaround for anyone blocked by the missing support for scheduled (time-delayed) local toast notifications in the Windows App SDK.

I implemented it in a .NET MAUI app by bypassing the Windows App SDK and calling the WinRT API directly (Windows.UI.Notifications.ScheduledToastNotification). The key points are:

  • Schedule it via LocalNotification.Schedule(...).
  • Important: it only works when the app is packaged as MSIX (debugging an unpackaged app from Visual Studio won’t show the notification).
  • No additional COM activator or manifest

I’ve published a small sample project here for reference: https://github.com/true-perfect-code/WinRT_API_LocalNotification

This might help others until the Windows App SDK officially supports scheduled local notifications.

pc

true-perfect-code avatar Aug 19 '25 18:08 true-perfect-code