Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Windows provides several notification APIs across different SDK generations. If you're searching online for how to send a notification and finding conflicting examples, this page will help you pick the right API for your app.
Which API should I use?
The answer depends on which SDK your app targets:
| App type | Recommended API | Namespace |
|---|---|---|
| WinUI 3 / Windows App SDK (new apps) | AppNotificationManager |
Microsoft.Windows.AppNotifications |
| WPF, WinForms, or unpackaged Win32 | AppNotificationManager via NuGet |
Microsoft.Windows.AppNotifications |
| UWP (existing apps, no migration planned) | ToastNotificationManager |
Windows.UI.Notifications |
Important
Most Stack Overflow answers and older tutorials use ToastNotificationManager from the Windows.UI.Notifications namespace. This is the UWP WinRT API. It works in UWP apps and may work in some desktop scenarios, but it is not the recommended path for new Windows App SDK apps. Use AppNotificationManager for new development.
Notifications API comparison
| Feature | AppNotificationManager (Windows App SDK) |
ToastNotificationManager (WinRT) |
|---|---|---|
| Recommended for | WinUI 3, WPF, WinForms, unpackaged Win32 | UWP |
| NuGet package | Microsoft.WindowsAppSDK |
None (inbox) |
| Package identity required | No (works packaged and unpackaged) | Required for some features |
| Push integration | PushNotificationManager (Windows App SDK) |
WNS channel APIs (Windows.Networking.PushNotifications) |
| Active development | Yes | Maintenance only |
Types of notifications
Once you've chosen the right API, decide how your notification will be delivered:
| Type | Description | Use when |
|---|---|---|
| Local app notification | Triggered directly by your app code while running | You want to alert the user of an in-app event |
| Scheduled | Set a future time for the notification to appear | Calendar reminders, alarms |
| Push (WNS) | Sent from your cloud service via Windows Push Notification Services | Chat messages, breaking news, real-time updates |
| Badge | Small overlay on the app's taskbar icon | Unread count, status indicator |
For a full breakdown of delivery methods, see Choose a notification delivery method.
Next steps
Building a WinUI 3 or Windows App SDK app?
- App notifications overview — local and push app notifications using
AppNotificationManager - App notifications quickstart
- Push notifications overview — WNS push using
PushNotificationManager
Building or maintaining a UWP app?
Migrating a UWP app to Windows App SDK?
Windows developer