Как отправить уведомление GCM в javascript.
Привет,
Как отправить уведомление в java script.
Спасибо
Басит.
Что я уже пробовал:
Я попробовал войти vb.net и его успешно отправили.
Как преобразовать приведенный ниже код или сделать это на javascript.
Private Sub Frm_SendNotification() RegId = "xxxxx" ApplicationID = "xxxxx" SENDER_ID = "xxxx" Dim value = TextBox1.Text 'message text box Dim tRequest As WebRequest 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)) 'Data post to the Server 'Dim postData As String = (Convert.ToString("collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "®istration_id=") & RegId) + "" Dim postData As String = (Convert.ToString("data.message=" + value + "®istration_id=") & RegId) + "" Console.WriteLine(postData) Dim byteArray As [Byte]() = Encoding.UTF8.GetBytes(postData) tRequest.ContentLength = byteArray.Length Dim dataStream As Stream = tRequest.GetRequestStream() dataStream.Write(byteArray, 0, byteArray.Length) dataStream.Close() Dim tResponse As WebResponse = tRequest.GetResponse() dataStream = tResponse.GetResponseStream() Dim tReader As New StreamReader(dataStream) Dim sResponseFromServer As [String] = tReader.ReadToEnd() 'Get response from GCM server Label1.Text = sResponseFromServer 'Assigning GCM response to Label text tReader.Close() dataStream.Close() tResponse.Close() End Sub