Exemplo n.º 1
0
        public void PushMesssageBroadcastMultiTest()
        {
            var messageList = new List <string>
            {
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
            };
            var messageKeyList = new List <string>
            {
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
            };

            var request = new MessagePushBroadcastRequest(
                DeviceTypes.Android,
                MessageTypes.Message,
                messageList,
                messageKeyList
                );

            Console.WriteLine("Push Message:" + request.Messages);

            var pushService = new Client(_apiKey, _secretKey);
            var response    = pushService.PushMessageBroadcast(request);

            Assert.NotNull(response);
            Assert.Greater(response.RequestId, 0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Push Message Broadcast (to all users)
        /// </summary>
        /// <param name="request">Push request parameter</param>
        /// <returns></returns>
        public MessagePushResponse PushMessageBroadcast(MessagePushBroadcastRequest request)
        {
            var postStr = request.GeneratePostData(Apikey, SecretKey);

            var response = PostData(request.ServiceUrl, postStr);

            if (response == null)
            {
                return(null);
            }

            MessagePushResponse result = null;

            try
            {
                result = JsonConvert.DeserializeObject <MessagePushResponse>(response);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("PushMessageBroadcast Error Response Deserialize Fail, May not valid json:" + ex.Message + " " + response);
            }
            return(result);
        }