GCM to Chrome sample?

285 views
Skip to first unread message

Martin Kristensen

unread,
Jun 25, 2015, 4:13:44 AM6/25/15
to gcm-for-chr...@googlegroups.com

Hello,


I've spent a lot of time now trying to get a simple working demo of GCM to work, but havn't succeeded.

I'm using ASP.NET and want to make a web app where I can send a downstream message to Chrome.


I've read:

https://developers.google.com/cloud-messaging/ and http://updates.html5rocks.com/2015/03/push-notificatons-on-the-open-web


And I've used all sample code associated with these sites for server/client, but no luck getting it to work.

I'm sure I've provided the right sender ID and Auth keys.



I'm not a javascript wizard, so I'm wondering if it's possible to get a more complete sample of GCM to Chrome for both server and client side?



Thanks,


Martin Kristensen

Filip Gorski

unread,
Jun 26, 2015, 1:27:01 PM6/26/15
to gcm-for-chr...@googlegroups.com
Hi, Martin,

Unfortunately I am not aware of good web push sample, but I reached out to devs who could.

Meanwhile here is a thing to try:

Here is a sample using chrome.gcm API: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/gcm-notifications, which works for chrome apps and extensions. It will generates a curl command that creates a request that sends a message to the app from the command line.

What you need to implement the web page using the second resource you've read, then when you get registration ID, substitute the APP_KEY and registration Id on the command line, to ensure that your web page actually receives web push messages.

Then you move on to the server implementation, you simply need to generate a request to gcm infrastructure in the same way as curl command. Details of the request available here: https://developers.google.com/cloud-messaging/server-ref#send-downstream

Thanks.
Filip

Peter Beverloo

unread,
Jun 26, 2015, 1:48:27 PM6/26/15
to gcm-for-chr...@googlegroups.com
Hi Martin,

In regards to complete examples using the Push API, I can point you to the following two GitHub repositories:


The former will give you a curl command to run, which allows you to test the client-implementation without depending on the server implementation.

The latter contains both the client and the server, implemented in Python. Hopefully this will be able to give you a more complete picture!

Thanks,
Peter

Martin Kristensen

unread,
Jul 16, 2015, 8:15:44 AM7/16/15
to gcm-for-chr...@googlegroups.com
Hi Filip,

Thanks for your reply.

I'm only interested in GCM for Chrome without the need to install extensions/apps from the store. Something like https://simple-push-demo.appspot.com/ - code which Peter Beverloo posted a link to.


My problem with the second resource I posted is that I cannot subscribe. Whenever getting into the function Subscribe I get told that probably my gcm_sender_id or gcm_user_visible_only contains the wrong info, which I'm quite sure it isnt.
I've made a post on Stackoverflow where I've posted some code and tried to explain in more detail: http://stackoverflow.com/questions/30782247/gcm-to-chrome-general-help-unable-to-subscribe-no-sender-id


Thanks,

Martin

Filip Gorski

unread,
Jul 16, 2015, 4:25:00 PM7/16/15
to gcm-for-chr...@googlegroups.com, Peter Beverloo
Making sure Peter sees the question. He is better equipped to help you.

thanks.
Filip

Martin Kristensen

unread,
Jul 17, 2015, 8:47:36 AM7/17/15
to gcm-for-chr...@googlegroups.com, pe...@chromium.org
I figured out where I went wrong.

Turns out I had to add .json MIME-type to IIS and add mimeMap to my Web.config.


Thank you both for the help.

Martin Kristensen

Peter Beverloo

unread,
Jul 17, 2015, 9:16:34 AM7/17/15
to Martin Kristensen, gcm-for-chr...@googlegroups.com, pe...@chromium.org
Hi Martin,

Glad that the mime-type fixed the problem for you. I'm not aware of Chrome actually validating the used mime-type, but perhaps it was something on IIS' side.

Please feel free to CC me directly on future e-mail with questions :-) (Thanks Filip!)

Peter

--
You received this message because you are subscribed to a topic in the Google Groups "GCM for Chrome feedback" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gcm-for-chrome-feedback/i3SB92vavDA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gcm-for-chrome-fe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages