Describe the bug
Using WNS template for send a notification produces outcome "The Notification payload is invalid"
Exception or Stack Trace
The outcome result is "The Notification payload is invalid"
To Reproduce
Create a WNS template using any example provided by Microsoft.
Send a notification using SendNotificationAsync or SendTemplateNotificationAsync
Code Snippet
static void Main(string[] args)
{
var connectionString = "Place your connection here";
var notificationHubClient = NotificationHubClient.CreateClientFromConnectionString(connectionString, "your notification hub", true);
Installation installation = new Installation();
installation.InstallationId = Guid.NewGuid().ToString();
installation.PushChannel = "Place your channel here";
installation.Platform = NotificationPlatform.Wns;
var template = new InstallationTemplate();
template.Body = @"<toast><visual><binding><text>Test +{$(object)}</text></binding></visual></toast>"; // Use any example
template.Headers = new Dictionary<string, string>() { { "X-WNS-Type", "wns/toast" } };
installation.Templates = new Dictionary<string, InstallationTemplate>
{
{
"WindowsToast",
template
}
};
notificationHubClient.CreateOrUpdateInstallationAsync(installation);
var props = new Dictionary<string, string> {
{ "object", "Any string" } };
var n = new TemplateNotification(props);
n.Headers.Add("X-WNS-Type", "wns/toast");
var outcome = notificationHubClient.SendNotificationAsync(n).GetAwaiter().GetResult();
Expected behavior
Receive notification.
Screenshots
N/A
Setup (please complete the following information):
OS: Windows 10
IDE : Visual Studio 2022 17.4.0
4.1.0
Additional context
I am creating a MAUI application, but this also fails with console, if instead of using SendNotificationAsync I try with SendWindowsNativeNotificationAsync it works fine.
Describe the bug Using WNS template for send a notification produces outcome "The Notification payload is invalid"
Exception or Stack Trace The outcome result is "The Notification payload is invalid"
To Reproduce
Code Snippet
Expected behavior Receive notification.
Screenshots N/A
Setup (please complete the following information):
Additional context I am creating a MAUI application, but this also fails with console, if instead of using SendNotificationAsync I try with SendWindowsNativeNotificationAsync it works fine.