php-firebase-cloud-messaging icon indicating copy to clipboard operation
php-firebase-cloud-messaging copied to clipboard

How to send an Image through notification or data message type?

Open gunalan87 opened this issue 7 years ago • 1 comments

I have tried the following code.

$message = new Message(); $message->setPriority('high'); $message->addRecipient(new Device('DEVICE_TOKEN')); $message ->setNotification(new Notification('Notification Title', 'Notification Body',"Image_URL")); //->setData(['key' => 'value']); $response = $client->send($message);

gunalan87 avatar Sep 18 '18 09:09 gunalan87

You can use this method to set the icon of the notification:

// android only, set the name of your drawable resource as string
$message->setIcon('name');

Or if you just want to send an image url and then capture it on client side you can send it as Data.

$notification->setData(['image_url' => 'absolute_path_of_image'])

redjanym avatar Sep 18 '18 10:09 redjanym