Home » Php » php – How we can send image and icon by using Firebase cloud messaging(fcm) for push notification in android

php – How we can send image and icon by using Firebase cloud messaging(fcm) for push notification in android

Posted by: admin July 12, 2020 Leave a comment

Questions:

I want to send an image and icon in my Push notification from my Serverside(php) to my app.
image of cat

I have searched on Google but was unable to get the proper result.
I get FCM PHP Code. I use these code for sending notification but when I use “image and icon” parameter image not receive in notification.

In GCM it’s easy to send icon and image in Push notification

 $fields = array(
    'registration_ids' => $registrationIDs,
    'data' => array(
        "title" => "SamplePush Application",
        "style" => "inbox"; //picture/inbox,
        "message" => "I am just testing Push notification",
        "notId" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "summaryText" => "Venha provar os nossos Gins",
        "image" => "http://gintonico.com/content/uploads/2015/03/fontenova.jpg",
        "picture" => "http://media5.letsbonus.com/products/285000/285006/14014409744462-0-1700x690.jpg"
    ) ,

If anyone can send image and icon in notification using FCM please help me.

How to&Answers:

Simply, I change my plugin and use phonegap-plugin-push v2.0.x and it work fine. Now I am able to send big image in the notification.

enter image description here

Answer:

Notification image must be PNG image. Replace jpg image with png image.