Skip to content

Instantly share code, notes, and snippets.

@sthewissen
Created November 14, 2017 14:14
Show Gist options
  • Save sthewissen/ad53bf8a302ab4ace6eef91e5299b51e to your computer and use it in GitHub Desktop.
Save sthewissen/ad53bf8a302ab4ace6eef91e5299b51e to your computer and use it in GitHub Desktop.

Revisions

  1. sthewissen revised this gist Nov 14, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion NotificationManager.cs
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,6 @@ public interface INotificationManager

    public class NotificationManager : INotificationManager
    {

    public async Task<bool> SendNotification(string message)
    {
    try
  2. sthewissen created this gist Nov 14, 2017.
    25 changes: 25 additions & 0 deletions NotificationManager.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    public interface INotificationManager
    {
    Task<bool> SendNotification(string message);
    }

    public class NotificationManager : INotificationManager
    {

    public async Task<bool> SendNotification(string message)
    {
    try
    {
    var hub = NotificationHubClient.CreateClientFromConnectionString(Constants.NotificationAccessKey, Constants.NotificationHubName);

    // Send the notification
    var result = await hub.SendAppleNativeNotificationAsync("{\"aps\":{\"alert\":\"" + message + "\", \"title\":\"" + message + "\", \"sound\":\"bingbong.aiff\"}}");

    return true;
    }
    catch (Exception)
    {
    return false;
    }
    }
    }