Hello!

I'm trying to send GCM message from C# to my android phone.
Unfourtenly, the hebrew message is not catched on my broadcast reciver - 
but if I send english message it's catched as expected.

The send code:

        private static string SendNotification(string id, string msg, 
string key)
        {
            try
            {
                ServicePointManager.ServerCertificateValidationCallback = 
(object sender, X509Certificate certificate, X509Chain chain, 
SslPolicyErrors sslPolicyErrors) => true;
                WebRequest request = 
WebRequest.Create("https://android.googleapis.com/gcm/send";);
                request.Method = "POST";
                // request.ContentType = 
"application/x-www-form-urlencoded;charset=UTF-8";
                request.ContentType = "application/x-www-form-urlencoded";

                request.Headers.Add(string.Format("Authorization: 
key={0}",  key));
                string collaspeKey = Guid.NewGuid().ToString("n");
                string postData = 
string.Format("registration_id={0}&data.message={1}&collapse_key={2}", id, 
msg, collaspeKey);
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentLength = byteArray.Length;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                WebResponse response = request.GetResponse();
                dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseFromServer = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();

                return responseFromServer;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

Please help me!
Yuval

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to