簡體   English   中英

Android推送通知:如何顯示標題?

[英]Android Push Notifications: How do I show a title?

我們正在使用Google Cloud Messaging API推送Android通知。 我們正在執行https://android.googleapis.com/gcm/send端點,其有效負載類似於:

{
  "registration_ids" : ["..."],
  "data" : {
    "message" : "You received cash back!"
  }
}

通知有效,手機會顯示我們的應用徽標以及上面的消息。 但是,通知中沒有標題(在消息上方和徽標右側):

示例截圖

作為參考,我們使用的是Phonegap 3.3和PhoneGap Build。

好吧,在黑暗中加入“標題”修復了它。 我無法在http://developer.android.com/google/gcm/server.html#params上找到此文檔

{
  "registration_ids" : ["..."],
  "data" : {
    "message" : "You received cash back!",
    "title" : "Title"
  }
}

現在在docs中: https//developers.google.com/cloud-messaging/server#payload

看看這里的文檔:

{
  "registration_ids" : ["..."],
  "notification" : {
    "body" : "You received cash back!",
    "title" : "Title",
    "icon": "ic_notification" // replace with your own
  }
}

編輯:現在不推薦使用雲消息傳遞,此示例不再有效。 更新文檔的鏈接位於firebase

它在我身邊

$ message = array(“message”=> $ pushMessage,“title”=>“我的通知”);
$ fields = array(“registration_ids”=>“ device id to send notification ”,“data”=> $ message);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM