Hii,
I want to use GCM for push message, followed all the steps from the article
: https://developer.android.com/google/gcm/gs.html
below is my code:
Private Sub send(ByVal regId As String)
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("Authorization:
key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
tRequest.Headers.Add("Sender: id=0000000000")
Dim collaspeKey As String = Guid.NewGuid().ToString("n")
Dim postData As String = "collapse_key=" & collaspeKey &
"&data.payload=" & Convert.ToString(txtMsg.Text) & "&data.time=" &
System.DateTime.Now.ToString() & "®istration_id=" & regId & ""
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()
lblStat.Text = sResponseFromServer
tReader.Close()
dataStream.Close()
tResponse.Close()
End Sub
***************************************************************************************************
on executing getresponse, google fires "The remote server returned an
error: (401) Unauthorized" error.
Please help me, what is wrong.
I have given both key as per the article described.
Thank you
--
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" 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/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net
---
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.