Beispiel #1
0
        private async Task SendNotificationAsync_SendAdmNativeNotification_GetSuccessfulResultBack()
        {
            LoadMockData();
            var notification = new AdmNotification("{\"data\":{\"key1\":\"value1\"}}");

            var notificationResult = await _hubClient.SendNotificationAsync(notification, "someRandomTag1 && someRandomTag2");

            Assert.Equal(NotificationOutcomeState.Enqueued, notificationResult.State);
            RecordTestResults();
        }
Beispiel #2
0
        public void AmazonAdm_Simple_Test()
        {
            var wait = new ManualResetEvent(false);

            var settings = new AdmPushChannelSettings("client_id", "client_secret");

            var adm = new AdmPushChannel(settings);

            var n = new AdmNotification();

            n.Data.Add("Test", "value");
            n.RegistrationId = "12345";

            adm.SendNotification(n, (sender, response) => wait.Set());

            wait.WaitOne();
        }
Beispiel #3
0
        public static AdmNotification WithData(this AdmNotification n, string key, string value)
        {
            if (n.Data == null)
            {
                n.Data = new Dictionary <string, string>();
            }

            if (!n.Data.ContainsKey(key))
            {
                n.Data.Add(key, value);
            }
            else
            {
                n.Data[key] = value;
            }

            return(n);
        }
Beispiel #4
0
        public static AdmNotification WithData(this AdmNotification n, IDictionary <string, string> data)
        {
            if (n.Data == null)
            {
                n.Data = new Dictionary <string, string>();
            }

            foreach (var item in data)
            {
                if (!n.Data.ContainsKey(item.Key))
                {
                    n.Data.Add(item.Key, item.Value);
                }
                else
                {
                    n.Data[item.Key] = item.Value;
                }
            }

            return(n);
        }
Beispiel #5
0
        internal static Notification BuildNotificationFromString(string notificationAsString, NotificationPlatform platform)
        {
            Notification notification = null;

            if (platform == 0)
            {
                JObject jobj = JObject.Parse(notificationAsString);
                Dictionary <string, string> templateProperties = jobj.ToObject <Dictionary <string, string> >();
                notification = new TemplateNotification(templateProperties);
            }
            else
            {
                switch (platform)
                {
                case NotificationPlatform.Wns:
                    notification = new WindowsNotification(notificationAsString);
                    break;

                case NotificationPlatform.Apns:
                    notification = new AppleNotification(notificationAsString);
                    break;

                case NotificationPlatform.Gcm:
                    notification = new GcmNotification(notificationAsString);
                    break;

                case NotificationPlatform.Adm:
                    notification = new AdmNotification(notificationAsString);
                    break;

                case NotificationPlatform.Mpns:
                    notification = new MpnsNotification(notificationAsString);
                    break;
                }
            }

            return(notification);
        }
Beispiel #6
0
        internal static Notification BuildNotificationFromString(string notificationAsString, NotificationPlatform platform)
        {
            Notification notification = null;

            if (platform == 0)
            {
                return(BuildTemplateNotificationFromJsonString(notificationAsString));
            }
            else
            {
                switch (platform)
                {
                case NotificationPlatform.Wns:
                    notification = new WindowsNotification(notificationAsString);
                    break;

                case NotificationPlatform.Apns:
                    notification = new AppleNotification(notificationAsString);
                    break;

                case NotificationPlatform.Gcm:
                    notification = new GcmNotification(notificationAsString);
                    break;

                case NotificationPlatform.Adm:
                    notification = new AdmNotification(notificationAsString);
                    break;

                case NotificationPlatform.Mpns:
                    notification = new MpnsNotification(notificationAsString);
                    break;
                }
            }

            return(notification);
        }
Beispiel #7
0
 public static AdmNotification WithExpiresAfter(this AdmNotification n, int expiresAfterSeconds)
 {
     n.ExpiresAfter = expiresAfterSeconds;
     return(n);
 }
Beispiel #8
0
 public static AdmNotification WithConsolidationKey(this AdmNotification n, string consolidationKey)
 {
     n.ConsolidationKey = consolidationKey;
     return(n);
 }
Beispiel #9
0
 public static AdmNotification ForRegistrationId(this AdmNotification n, string registrationId)
 {
     n.RegistrationId = registrationId;
     return(n);
 }