I have configured a .NET App Service using the "Quick Start" instructions in the newer Azure Portal to publish an app service to use as my mobile back end. I have also configured a notification hub for it and am able to send push notifications from a Xamarin.Forms Android app via the Azure mobile back end endpoint. I can also receive the push notification on a registered Android device.
I need to be able to send push notifications to registered devices from a C# console application but no matter what I try, the push messages are not delivered.
I am using the following code to attempt to send push messages. When I run it, the execution ends on...
var result = await hub.SendTemplateNotificationAsync(templateParams);
...and console app terminates without waiting for the response and the push notification is never delivered to the registered device.
public async void PushSmartAlerts()
{
string notificationHubName = "DevXXXXNotificationHub";
string notificationHubConnection = "Endpoint=sb://devXXXXXnotificationhubnamespace.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=SnXXXXXXXXXXXXXXXXXXXXXXXX9N8=";
hub = NotificationHubClient .CreateClientFromConnectionString(notificationHubConnection, notificationHubName);
Dictionary<string, string> templateParams = new Dictionary<string, string>();
templateParams["messageParam"] = "Hello";
var result = await hub.SendTemplateNotificationAsync(templateParams);
}
Can anyone tell me what is wrong or if I am going about it the wrong way?