Firebase通知包含标题和消息

时间:2017-08-10 20:39:23

标签: android firebase notifications firebase-notifications

我正在使用this教程使用push notification

发送Firebase

如何在通知栏Title and Message中显示 enter code here (我仍然将 message 显示为{{1}通知栏中的内容)...

正如您在this *Title*中看到的那样(由于这个原因,我{}} screenshot unable向用户完成deliver,因为在通知栏标题中有限制*message along with Title*

我正在使用maximum 1 line来传递这样的通知:

Advanced Rest Client (Messaging API)

代码

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIza************adrTY

{ "data": {
    "image": "https://ibin.co/2t1lLdpfS06F.png",
    "message": "Firebase Push Message Using API"
    "AnotherActivity": "True"
  },
  "to" : "f25gYF3***********************HLI"
}

1 个答案:

答案 0 :(得分:1)

使用

writer.writerows(inspect.getmembers(i)[1:3] for i in list_people) 设置标题和通知

setContentTitle("title")设置文字。

A example from Android Developers:

setContentText("text")

在您的情况下,您必须将代码更改为:

NotificationCompat.Builder mBuilder =
    new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.notification_icon)
    .setContentTitle("My notification")
    .setContentText("Hello World!");

如果您想支持新的Android O通知,我建议您花一些时间学习NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setLargeIcon(image) .setSmallIcon(R.drawable.firebase_icon) .setStyle(new NotificationCompat.BigPictureStyle() .bigPicture(image))/*Notification with Image*/ .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent) .setContentTitle(messageTitle) // here .setContentText(messageBody); // and here

NotificationChannel example