Notification Hub cross platform push using latest Microsoft.Azure.NotificationHubs namespace RRS feed

  • Question

  • I need to send a push notification to mobile devices that have registered on my notification hub.

    The hub is set up to allow windows phone, apple and android devices to register, and I have the appropriate keys and certificates in place. (According to the documentation!)

    I can see that I have at least one of each type of device registered on my hub, and they have registered with a tag that I can use to send a notification to a specific device.

    I am using C# and the latest release of the Microsoft.Azure.NotificationHubs namespace, version 2.16, as advised by the NuGet package manager.

    I want to send a notification to a device that has registered using a tag.

    The documentation says that I can send one message to the notification hub, and the hub will create a platform specific notification to forward on.

    My question is what method do I use to send the data to the hub from the back end, and therefore, what parameters do I use in that method.

    I am trying to use the SendNotificationAsync() method that takes a Dictionary and a string tag as parameters.

    I don't know what to set in the Dictionary parameters, or in the properties of the Notification class , i.e. Body, ContentType, Headers etc. I cannot find any examples using these classes.

    I know this namespace is new, but I can find no examples of how to use the methods.

    Any help appreciated.

    I know these have only just been released, but any help / guidance would be appreciated.

    Wednesday, September 2, 2015 12:56 PM


  • Hi Andrey,

    Take a look at https://msdn.microsoft.com/en-us/library/azure/Dn530748.aspx?f=255&MSPPError=-2147217396 for an overview on templates. For Notification Hubs to send cross-platform notifications, each device needs to have a platform-specific template payload registration. This is why when the backend sends a dictionary (placeholder: payload to be switched in), the service does that filling. The tutorials at https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-ios-send-localized-breaking-news/ and https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-windows-store-dotnet-send-localized-breaking-news/ utilize our template concept and demonstrates the workflow. They will likely be helpful. Please let me know if you have any other questions.



    Thursday, September 10, 2015 12:38 AM