Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (35 sloc) 1.34 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Notifications;
namespace MyFitnessTrackerLibrary.ServiceBus
{
// TODO: Replace this with a connection to the notification central hub, do not sent message directly from here in the future!!!!
public class NotificationGateway
{
private NotificationHubClient hub = null;
private static NotificationGateway _notificationGateway;
public NotificationGateway()
{
hub = NotificationHubClient.CreateClientFromConnectionString(MyFitnessTrackerLibrary.Globals.MyFitAppSettings.NotificationHubConnectionString, MyFitnessTrackerLibrary.Globals.MyFitAppSettings.NotificationHubName);
}
~NotificationGateway()
{
}
public async Task<NotificationOutcome> SendMessage(string message)
{
var toast = "{ \"data\" : {\"message\":\"" + "From : " + message + "\"}}";
return await hub.SendGcmNativeNotificationAsync(toast);
}
public static NotificationGateway GetInstance()
{
if(_notificationGateway == null)
{
_notificationGateway = new NotificationGateway();
}
return _notificationGateway;
}
}
}