【问题标题】:How to push notification from rest client for testing purpose如何从休息客户端推送通知以进行测试
【发布时间】:2014-09-24 04:55:50
【问题描述】:

您好,我正在尝试将通知从 rest 客户端推送到 android 应用程序。我正在做如下 -

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

我总是收到这条消息

状态码:401 未经授权 替代协议:443:quic,p=0.002 缓存控制:私有,max-age=0

我不确定自己遗漏了什么,最后我使用了正确的服务器 api 密钥。

请提前帮助和感谢。

【问题讨论】:

标签: php android google-cloud-messaging rest-client


【解决方案1】:

推送通知使用Web Socket。除非您设置了服务器端实现以通过 Web Socket 响应您的请求,否则您无法使用 HTTP protocol 执行此操作。

【讨论】:

    【解决方案2】:

    我在标题中设置了这个值,然后它对我来说很好。

    下面是标题键和值。

    A) 授权:& 它的值喜欢 key=API_KEY

    B) 内容类型: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"
        }
      }
      

      希望对你有帮助

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-12-10
        • 1970-01-01
        • 1970-01-01
        • 2019-07-06
        • 1970-01-01
        • 2011-07-30
        • 2023-03-24
        • 2010-11-06
        相关资源
        最近更新 更多