Created
November 14, 2017 14:14
-
-
Save sthewissen/ad53bf8a302ab4ace6eef91e5299b51e to your computer and use it in GitHub Desktop.
Notification manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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