FCM/GCM JSON有效负载-如何指定大图标? [英] FCM/GCM JSON payload - How to specify a large icon?
问题描述
我正在使用Firebase端点发送推送通知.运行正常.我正在使用邮递员将请求发送到FCM.我的问题是我不知道如何使用它发送大图标.
I am sending a push notification using firebase endpoint. It is working successfully. I am using postman to send the request to FCM. My issue is I do not understand how to send a large icon with it.
FCM可以发送两种类型的有效负载.数据有效载荷和通知有效载荷. 请参见此处.我专注于通知有效负载.如何指定要显示的本地大图标?我知道我可以使用元数据以这种方式在清单中指定默认的通知图标:
FCM has two types of payloads you can send. Data payloads and notification payloads. See here. I'm focusing on notification payloads. How do I specify a local large icon to show ? I know I can specify a default notification icon in the manifest this way using metadata:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/mylogo" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/mycolor" />
但这是一个小图标.如何指定我要使用的大图标?
But this is for a small icon. How do I specify LARGE icon I'd like to use ?
在我上面为FCM提供的文档中,有一个类似于以下示例:
In the documentation I provided above for FCM, there is a example that looks like this:
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}
但这是用于小图标的.怎么做大图标?
but this is for small icon. how to do large icon?
一个大图标看起来像这样:
A large icon looks like this:
推荐答案
FCM没有用于设置大图标的API.
FCM doesn't have an API to set a large-icon.
如果要实现此目的,可以发送带有自定义有效负载的data-message
,并在onMessageReceived()
If you want to achieve that you can send a data-message
with custom payload, and create your own local notification inside onMessageReceived()
这篇关于FCM/GCM JSON有效负载-如何指定大图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!