Notifications Toast c #

1

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.

    
asked by anonymous 14.08.2016 / 03:03

1 answer

3

You must use the Azure Notification Hub service.

Send push notifications to any platform and from any backend

  • Reach all major platforms: iOS, Android, Windows, Kindle, Baidu Use any backend: in the cloud or local
  • Push fast to millions of mobile devices with a single API call
  • Customize push notifications by user, language, and location
  • Dynamically define and notify user segments
  • Instantly scale to millions of mobile devices

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:

Azure Notification Hub Example .

    
15.08.2016 / 09:51