【发布时间】:2018-07-03 02:42:38
【问题描述】:
我正在开发一个集成了 Firebase 来处理通知的应用程序。我只想知道如何获取从后端团队发送给我的主题名称。其中包含三个主题,根据主题,我必须以不同的布局显示消息。我得到这样的标题和正文:
if (remoteMessage.getData().size() > 0) {
//handle the data message here
try {
String title = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
Log.e("TITLE AND BODY", title + "\n" + body);
} catch (Exception e) {
e.printStackTrace();
}
}
【问题讨论】:
-
通知如何在远程消息中发送主题。
-
{ "message":{ "topic" : "foo-bar", "notification" : { "body" : "这是 Firebase 云消息传递主题消息!", "title" : " FCM 消息”,} } }
-
是的,我知道这个@RatilalChopda 实际上看到了获取正文和标题我们写 String title = remoteMessage.getNotification().getTitle();字符串正文 = remoteMessage.getNotification().getBody();但是要获取主题,没有像 remoteMessage.getTopic() 这样的方法
标签: android firebase firebase-cloud-messaging android-notifications