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)