How to push notification from rest client for testing purpose

て烟熏妆下的殇ゞ 提交于 2019-12-07 19:03:29

问题


Hi I am trying to push the notification from rest client to android app. I am doing like below -

URL - https://android.googleapis.com/gcm/send
Method - POST
Headers - Authorization: my_server_key

I always get this message

Status Code: 401 Unauthorized Alternate-Protocol: 443:quic,p=0.002 Cache-Control: private, max-age=0

I am not sure what I am missing & last I am using correct server api key.

Please assist & thanks in advance.


回答1:


Push notification uses Web Socket. You cannot do this using HTTP protocol unless you have a server side implementation set up to respond to your request through Web Socket.




回答2:


I set this values in the header then it is working fine for me.

Below is the header key & value.

A) Authorization: & it value likes key=API_KEY

B) Content-Type: application/json




回答3:


  I hope you are done with your request but it will help to others

You have to send like this
In head
-------
Headder             Value

Authorization      key=your value
Content-Type       application/json

In Body
-------
Something like this
{
  "registration_ids" : ["Your id"],
  "data" : {
    "message":"Your message"
  }
}

Hope it will help



来源:https://stackoverflow.com/questions/26008860/how-to-push-notification-from-rest-client-for-testing-purpose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!