Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Push up notification for google chrome.

I have created FCM cloud messaging services in google.

I have two question

1) How to get the register ID of Google Chrome.
2) How to send the message to client/Google Chrome.

What I have tried:

I did in android to send the message with the below code.

i got the google chrome id from GCM Notification extension from chrome extension.

then i tried to send with below code saying senderIDMismatch, below code working fine in android device.

C#
Private Sub Frm_SendNotification()

        Dim RegId As String
        Dim ApplicationId As String
        Dim SENDER_ID As String


        RegId = ""
        ApplicationId = ""
        SENDER_ID = ""
        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() + "&registration_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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900