我在试着运行GCM演示。我已经在我的手机上构建并安装了这个应用程序,现在我正试图用这个帖子来激活推送。
我生成了Googleservices.json文件,在此过程中获得了一个服务器密钥(API_KEY)和一个发件人ID (SID)。(发送方ID是否是“to”设备/应用程序令牌?)
我试着用这个帖子发送:
curl -vvv -X POST --header "Content-Type: application/json" --header "project_id: default-demo-app-92a8c" --header "Authorization: key=<<API_KEY>>" --data @- "https://android.googleapis.com/gcm/send" << EOF
{
"to": "<<SID>>",
"data": {
"message":"Hello"
}
}
EOF
以下是我们的回应:
* Trying 74.125.29.95...
* Connected to android.googleapis.com (74.125.29.95) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.googleapis.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> POST /gcm/send HTTP/1.1
> Host: android.googleapis.com
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> project_id: default-demo-app-92a8c
> Authorization: key=AIzaSyA2GFGsoIeppqKRTpSc6m4sffGD8dzqryY
> Content-Length: 58
>
* upload completely sent off: 58 out of 58 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=UTF-8
< Date: Tue, 26 Jan 2016 21:46:48 GMT
< Expires: Tue, 26 Jan 2016 21:46:48 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alternate-Protocol: 443:quic,p=1
< Alt-Svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"
< Accept-Ranges: none
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
<
INVALID_REGISTRATION
* Connection #0 to host android.googleapis.com left intact
我为什么要犯这个错误?
https://stackoverflow.com/questions/35024748
复制相似问题