[英]Android Push Notifications: How do I show a title?
We are using the Google Cloud Messaging API to push Android notifications. 我们正在使用Google Cloud Messaging API推送Android通知。 We are executing the https://android.googleapis.com/gcm/send endpoint with a payload similar to:
我们正在执行https://android.googleapis.com/gcm/send端点,其有效负载类似于:
{
"registration_ids" : ["..."],
"data" : {
"message" : "You received cash back!"
}
}
The notification works and the phone shows our app logo, and the message from above. 通知有效,手机会显示我们的应用徽标以及上面的消息。 However, there is no title in the notification (above the message and to the right of the logo):
但是,通知中没有标题(在消息上方和徽标右侧):
For reference, we are using Phonegap 3.3 and PhoneGap Build. 作为参考,我们使用的是Phonegap 3.3和PhoneGap Build。
Well, a stab in the dark of adding "title" fixed it. 好吧,在黑暗中加入“标题”修复了它。 I wasn't able to find this documented at http://developer.android.com/google/gcm/server.html#params
我无法在http://developer.android.com/google/gcm/server.html#params上找到此文档
{
"registration_ids" : ["..."],
"data" : {
"message" : "You received cash back!",
"title" : "Title"
}
}
Now in docs: https://developers.google.com/cloud-messaging/server#payload 现在在docs中: https : //developers.google.com/cloud-messaging/server#payload
Have a look at the documentation here : 看看这里的文档:
{
"registration_ids" : ["..."],
"notification" : {
"body" : "You received cash back!",
"title" : "Title",
"icon": "ic_notification" // replace with your own
}
}
Edit: cloud messaging is now deprecated and this example is no longer valid. 编辑:现在不推荐使用云消息传递,此示例不再有效。 The link to the updated documentation is at firebase
更新文档的链接位于firebase
its working my side 它在我身边
$message = array("message" => $pushMessage,"title" => "My Notification"); $ message = array(“message”=> $ pushMessage,“title”=>“我的通知”);
$fields = array( "registration_ids" => " device id to send notification
", "data" => $message ); $ fields = array(“registration_ids”=>“
device id to send notification
”,“data”=> $ message);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.