Hello @Rohan Pande ,
To double-check this behavior, I built a quick native C++ Win32 repro without the Windows App SDK. While it compiles perfectly using just the Windows SDK, calling PushNotificationChannelManager::CreatePushNotificationChannelForApplicationAsync() in a truly unpackaged process results in an HRESULT 0x80070490 (Element not found) error. However, when I packaged that exact same executable with external location (sparse packaging) and ran it again, the API successfully requested and received a channel URI from WNS. This confirms that if your app is truly unpackaged, invoking this native API directly from C++ will typically fail, but granting it an identity unlocks the native feature.
The reason the Windows App SDK is often mentioned in these scenarios is that it provides an alternative client API (Microsoft.Windows.PushNotifications.PushNotificationManager). This alternative approach leverages Azure Active Directory for identity, essentially bypassing the OS's strict package identity requirement.
Regarding your deployment scenarios, if you prefer to use WNS without the Windows App SDK, your application would need to be either MSIX packaged or "packaged with external location". This approach grants your Win32 application the necessary package identity while allowing you to keep your existing executable and custom installer. Truly unpackaged apps without the SDK would generally not be supported for WNS.
On the other hand, if you choose to use the Windows App SDK to handle notifications, it might be helpful to note that you don't actually need to migrate your UI to WinUI 3. You can simply integrate the SDK into your existing Win32/WinUI 2 project. However, please keep in mind that for a completely unpackaged app, the App SDK's push notifications only support limited functionality, primarily foreground notifications without background COM activation.
For further reading, I'd suggest taking a look at a few specific Microsoft documents that outline these nuances:
- The Quickstart for Push notifications in the Windows App SDK contains a "Packaging requirements" table that confirms the limited functionality for truly unpackaged applications.
- To explore the native route, the Grant package identity by packaging with external location documentation illustrates how you might unlock push notifications without altering your current deployment model.
- Additionally, the WNS overview clarifies that the classic channel request methods are geared towards UWP or applications holding a package identity.
I hope this helps clarify the underlying requirements and provides some guidance on whether to adopt sparse packaging or integrate the App SDK for your current architecture. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.
Thank you.