how to make a request to GCM to send a notificatio

2019-06-10 00:28发布

问题:

actually i want to make a request to GCM to send a notification through XHR I already make request to GCM using the cURL utility but i don't know how to do it with XHR. Is there any way to do that

回答1:

Good news! There's a dedicated page as well as a demo of your inquiry in the documentation!



回答2:

You can not. At least, not directly because GCM API does not include CORS headers so it is not intended to be used from the browser. You need to send a signal to your own server and replicate the cURL command as the answer of that signal. See my other response: How to send push notifications in Chrome(Progressive Web Apps)