Following this tutorial I am trying to register my chrome browser to the GCM but I can't subscribe the browser:
I am trying to do the same as the following examples without the button. Once you accept the permision request, I want to get the subscription id but it doesn't work:
Here is the project if you want to check the code:
Thank you.
The problem with the example project you give is that the Service Worker never gets ready.
This is due to the location of your service worker js file. It is stored in the
js
directory, so its scope are only the pages located in this directory, and the page requesting for the service worker is in the root dir.To make a service worker available for the whole site, you must put it in the site's root directory.
According to the W3C specification, you can also set the Service Worker's scope manually by setting the
scopeURL
option in thenavigator.serviceWorker.register()
call.