Exemplo n.º 1
0
        /// <summary>
        /// For Quick Test Get Method
        /// </summary>
        /// <typeparam name="TResult">Result to deserialize object type</typeparam>
        /// <param name="url">url to post</param>
        public static async Task <TResult> Get <TResult>(string url)
        {
            var response = await NotificationClientManager.GetClient().GetAsync(url).ConfigureAwait(false);

            var mobileResult = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <TResult>(mobileResult);

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// For Quick Test Post Method
        /// </summary>
        /// <typeparam name="TResult">Result to deserialize object type</typeparam>
        /// <typeparam name="TPost">Type to be posted</typeparam>
        /// <param name="value">post value to be serialized</param>
        /// <param name="postUrl">Post url</param>
        public static async Task <TResult> Post <TResult, TPost>(TPost value, string postUrl)
        {
            var response = await NotificationClientManager.GetClient().PostAsync(postUrl,
                                                                                 new StringContent(JsonConvert.SerializeObject(value, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }),
                                                                                                   Encoding.UTF8, "application/json")).ConfigureAwait(false);

            var mobileResult = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <TResult>(mobileResult);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns successful statement
        /// </summary>
        /// <returns></returns>
        public static async Task <bool> SendNotification(OneSignalNotification notification)
        {
            try
            {
                var response = await NotificationClientManager.Post <object, OneSignalNotification>(notification, OneSignalConfiguration.URL_Notification_POST);

                return(response != null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                return(false);
            }
        }
Exemplo n.º 4
0
        public static async void SendNotification(string playerId, NotificationLocalizatedContent content)
        {
            var response = await NotificationClientManager.Post <Object, OneSignalNotification>(new OneSignalNotification
            {
                android_group      = "test",
                contents           = content,
                priority           = 10,
                include_player_ids = new List <string> {
                    playerId
                },
                small_icon = "icon",
            }, OneSignalConfiguration.URL_Notification_POST);

            var test = response;
        }