sagichnicht<<
New Member
I am new to .net and using .net as a server side for GCM push notification. I am using the below code and it working fine for single user(for below regId).My question is how to save all reg-id's in our .net server? I don't know whether it save in our server or not.If not saving the registered-id's then how to send push notifications to all registered users?\[code\] protected void Button1_Click(object sender, EventArgs e) { string regId = "APA91bFUgrdgtdgfdgxxxxxxxxxxxxxxxxxxxxxxxxxx6t1QDCn-4IiIAtvBhEt328QeYeLKoDeDFOgumrgACdydLCLvM0wM59nAzm_fZse3ta_A";//server api key var applicationID = "AIzaSDGjvbnviiuteuoidsgdfsdryiIfgA"; var SENDER_ID = "77xxxxxx25"; var value = http://stackoverflow.com/questions/13858630/Label1.Text; //message box label WebRequest tRequest; tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send"); tRequest.Method = "post"; tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8"; tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID)); tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID)); // string postData = "http://stackoverflow.com/questions/13858630/{'registration_id': [ '" + regId + "' ], 'data': {'message': '" + txtMsg.Text + "'}}"; string postData = "http://stackoverflow.com/questions/13858630/collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "®istration_id=" + regId + ""; Console.WriteLine(postData); Byte[] byteArray = Encoding.UTF8.GetBytes(postData); tRequest.ContentLength = byteArray.Length; Stream dataStream = tRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse tResponse = tRequest.GetResponse(); dataStream = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStream); String sResponseFromServer = tReader.ReadToEnd(); Label3.Text = sResponseFromServer; tReader.Close(); dataStream.Close(); tResponse.Close(); }\[/code\]Now i am getting push notifications in my android device like this and how to send or get text messages like "hii","test"... rather than "you got tickle".please help me..