3
votes

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 am using the latest release of the Microsoft.Azure.NotificationHubs namespace, version 2.16, as advised by the NuGet package manager.

I want to send one message, to all registrations as well as sending a message to a specific device. I can see the devices have all registered correctly with the hub, and have tags that allow me to send notifications to them.

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

I have also tried the SendNotificationAsync() method that takes a Notification object as a parameter.

Neither method causes a notification to appear on my windows phone with the parameters I have provided, so without an example or more information from the help files, I am stuck.

I cannot find any current examples using these methods and classes. The examples I have found pre-date the release, and do not show what to send to the notification hub for a cross platform notification to work.

I know these have only just been released, but any help / guidance would be appreciated, as I have reached a complete dead-end with this.

1

1 Answers

0
votes

Just a quick update...

Although I never got this to work as I wanted to (as described above), what I ended up doing was to use each platforms native notification as below;

var result1 = await hub.SendMpnsNativeNotificationAsync(windowstoast, mobileDeviceId);

var result2 = await hub.SendGcmNativeNotificationAsync(androidToast, mobileDeviceId);

var result3 = await hub.SendAppleNativeNotificationAsync(iOStoast, mobileDeviceId);

The 'toast' was formatted as per the individual platforms requirements in the documentation. The 'mobileDeviceId' was the tag that each device registered with the notification hub.

So, clumsy, but it works reliably to achieve the same end.

I still would like to get the cross platform way to work though. Will look into it a bit more when I have time.