Exemple #1
0
 public Task Register(string deviceToken, PushNotificationServicePlatform platform)
 {
     return(Client.PostAsync <string>("account/pushnotifications/" + Uri.EscapeDataString(deviceToken),
                                      new PushNotificationRegistration
     {
         Platform = platform
     }, logger: Logger));
 }
Exemple #2
0
        public void Add(Guid accountId, string deviceToken, PushNotificationServicePlatform platform)
        {
            using (var context = _contextFactory.Invoke())
            {
                var devices = context.Set <DeviceDetail>().Where(d => d.DeviceToken == deviceToken);

                context.Set <DeviceDetail>().RemoveRange(devices.Where(d => d.AccountId != accountId));

                if (devices.None(d => d.AccountId == accountId))
                {
                    var device = new DeviceDetail
                    {
                        AccountId   = accountId,
                        DeviceToken = deviceToken,
                        Platform    = platform
                    };
                    context.Set <DeviceDetail>().Add(device);
                }

                context.SaveChanges();
            }
        }
        public void Send(string alert, IDictionary <string, object> data, string deviceToken, PushNotificationServicePlatform platform)
        {
            switch (platform)
            {
            case PushNotificationServicePlatform.Apple:
                EnsureApnsStarted();
                SendAppleNotification(alert, data, deviceToken);
                break;

            case PushNotificationServicePlatform.Android:
                EnsureGcmStarted();
                SendAndroidNotification(alert, data, deviceToken);
                break;

            case PushNotificationServicePlatform.BlackBerry:
                EnsureBlackberryStarted();
                SendBBNotification(alert, data, deviceToken);
                break;

            default:
                throw new NotImplementedException();
            }
        }