Notification with C# Framework, is it okay?

Asked

Viewed 488 times

1

I wonder if you have a way for me to use hub notification or other type of notifications with the C# Framework? If there’s a way someone has an example?

  • this suits you: https://docs.microsoft.com/pt-br/azure/notification-hubs/notification-hubs-aspnet-backend-windows-dotnet-wns-notification

  • This is for c# but for html.

1 answer

0


See if this example is what you’re looking for: https://github.com/thiagolunardi/AzureNotificationHub

To receive notifications, simply register the app like this:

private async void InitNotificationHubAsync()
{
   var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

   var hub = new NotificationHub("NOME_DO_SEU_APP", "Endpoint=sb://NOME_DO_SEU_APP.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=CHAVE_COMPARTILHADA_DO_SEU_APP");
   await hub.RegisterNativeAsync(channel.Uri);
}

And to send notifications:

var hub = NotificationHubClient
            .CreateClientFromConnectionString("Endpoint=sb://NOME_DO_SEU_APP.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=CHAVE_DO_SEU_APP",
            "NOME_DO_SEU_APP");

var toast = @"<toast><visual><binding template=""ToastText01""><text id=""1"">Bem vindos ao VSSummit 2015</text></binding></visual></toast>";
var toastWithImage = @"<toast><visual><binding template=""ToastImageAndText01""><image id=""1"" src=""https://cdn1.iconfinder.com/data/icons/metro-ui-icon-set/512/Visual_Studio_2012.png"" /><text id=""1"">Bem vindos ao VSSummit15!</text></binding></visual></toast>";
hub.SendWindowsNativeNotificationAsync(toast).Wait();

Since my repository is dated, see if there have been any changes in the documentation of Azure Notification Hub.

  • Question Thiago: is it possible for me to subscribe to my Console app or Windows Forms to receive notifications, and I can perform some action based on what comes (like a push, for example)?

  • Um, notification only Windows 10 apps get. But what you’re looking to do is message processing. Browse Azure Event Hub. It’ll be more what you’re looking for.

  • I’ll search, thanks for the tip.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.