Hello, how can I use Azure to notify the user who has new content in the app? I'm creating a project in c#
to Windows 10
. Thank you in advance.
Hello, how can I use Azure to notify the user who has new content in the app? I'm creating a project in c#
to Windows 10
. Thank you in advance.
You must use the Azure Notification Hub service.
Send push notifications to any platform and from any backend
To trigger the backend notification:
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();
There are other templates / templates of notification like, simple message, with or without image, with or without title, with counters, etc. See other toast notifications templates.
And to make your app receive notifications:
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);
}
In my GitHub repository has an example of how to consume the service: