Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

notification with icon

like image 568
j2emanue Avatar asked Jan 21 '17 01:01

j2emanue


People also ask

How do I send a picture in FCM notification?

Build the send requestIn your notification send request, set the following AndroidConfig option: notification. image containing the image URL.

What is difference between FCM and GCM?

FCM is the new version of GCM under the Firebase brand. It inherits GCM's core infrastructure to make sure we continue to deliver messages reliably on Android, iOS and Chrome. Save this answer.

Is there any limit for FCM?

For Android, you can send up to 240 messages/minute and 5,000 messages/hour to a single device.


1 Answers

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()

like image 98
Diego Giorgini Avatar answered Sep 21 '22 22:09

Diego Giorgini