FCM/GCM JSON payload - How to specify a large icon

2019-06-20 17:37发布

问题:

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 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 ?

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:

回答1:

FCM doesn't have an API to set a large-icon.

If you want to achieve that you can send a data-message with custom payload, and create your own local notification inside onMessageReceived()