I am currently replacing PostSharp with an Azure notification hub, as the post-sharp seems to have stopped working in Azure. I have my application configured and it registers its device tag using Azure. I tested the push notification from the Azure Broadcast Portal for everyone and it works.
However, I want to modify the web API project to send notifications to a specific device. Here is the code I got so far where the device tag is the iPhone device tag:
var alert = "{\"aps\":{\"alert\":\"Hello from .NET!\"}}";
await hub.SendAppleNativeNotificationAsync(alert, new List<string> { deviceTag });
However, this does not work. I thought I could just send a device tag similar to how post-cutting works? I am a little confused, because I know that this device successfully registered in the hub in Azure, because if I perform a test broadcast from the portal, it receives a notification. How to change the API code to send to a specific device? I stumbled upon this article https://azure.microsoft.com/en-gb/documentation/articles/notification-hubs-aspnet-backend-windows-dotnet-wns-notification/ , but this seems strange since I already know the token devices. Can I send a notification to the hub and specify a device tag?
source
share