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.
Notification manager
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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment