Notification with C # Framework, is it okay?

1

I would like to know if you have how I can use notification hub or other notifications with the C # Framework? If so, how does anyone have an example?

    
asked by anonymous 05.10.2017 / 15:45

1 answer

0

See if this example is what you are looking for: link

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();

As this my repository is dated, see if there have been any changes to the Azure Notification Hub < a>.

    
09.10.2017 / 09:17