我們的項目已經被列入白名單用於測試新的GCM User Notifications API,允許分組的註冊ID,到那時,可用於發送郵件,並根據所擁有的所有設備的單一的「通知」「鍵registration_ids」場用戶。GCM用戶通知:缺少
然而,當我發送這樣的請求:
POST /gcm/send
Authorization: key=…
Content-Type: application/json
{"notification_key": "…",
"data": {…}
}
我得到一個錯誤響應:
400 Bad Request
Missing "registration_ids" field
使用registration_ids
字段發送消息,而不是notification_key
修正的問題(和消息得到交付),但使用用戶通知API的全部要點是使用notification_key
而不是registration_ids
。
registration_ids
: [...]的請求必須包括一個接收者這可以是一個註冊ID,註冊ID的陣列,或一個notification_key。需要。
notification_key
: 單個用戶與該用戶相關聯的多個註冊ID映射的字符串。這允許第三方服務器將單條消息發送給單個用戶擁有的多個應用實例(通常位於多個設備上)。第三方服務器可以使用notification_key作爲消息的目標,而不是單獨的註冊ID(或註冊ID陣列)。 […] 可選的。
上述示例使用HTTP連接服務器https://android.googleapis.com
。
到目前爲止我嘗試:
- 包括用於
registration_ids
空數組,並不能幫助 - 發送
notification_key
值作爲registration_ids
字段一個註冊ID,無法正常工作或 - 將
project_id
標題設置爲我們的項目編號(創建notification_key
時需要),仍然沒有運氣 - 使用CCS(XMPP)代替HTTP與GCM API服務器進行通信,但不幸的是the IP is blocked on Google App Engine
- 既包括
notification_key
和請求notification_key_name
,不利於
UPDATE:每個建議here作爲,我也試過張貼有效載荷/gcm/notification
,與"operation": "send"
屬性包含在JSON請求負載。仍然沒有幫助。現在,我得到:
{"error":"Missing \"registration_ids\" field"}
同樣的事情,只是這一次它被送回JSON編碼。
'registration_ids '一旦設備獲得了GCM註冊,就會得到一些東西。您必須先將此ID存儲到您的數據庫中,然後使用它來發送通知 –
@SunilMishra我可以使用'registration_ids'生成'notification_key',然後我應該能夠使用'notification_key' *來代替*'registration_ids'。 –
您是否嘗試過在請求中同時包含'notification_key'和'notification_key_name'? – Eran